Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Why can't i build my simple program in MPLAB??PLEASE HELP!!!!:(

Status
Not open for further replies.

aldrinsi

New Member
i'm new in microcontroller, and i'm using PIC16F84A. Can somebody please tell me what's wrong with my program, i just wish to set portA and portB as output and illuminate LED which will be connected to the ports.

#INCLUDE P16F84A.INC

__config _XT_OSC & _CP_OFF & _PWRTE_OFF & _WDT_OFF

MOVLW 0x00
BSF STATUS, RP0
MOVWF TRISA
MOVWF TRISB
BCF STATUS, RP0
MOVLW 0xFF
MOVWF PORTA
MOVWF PORTB

end
here's the error:
----------------------------------------------------------------------
Release build of project `C:\Documents and Settings\Admin\Desktop\Group8\blinkingLED.mcp' started.
Fri Jul 17 19:33:37 2009
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F84A "blinkingLED.asm" /l"blinkingLED.lst" /e"blinkingLED.err" /o"blinkingLED.o"
Error[152] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 6 : Executable code and data must be defined in an appropriate section
Error[152] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 7 : Executable code and data must be defined in an appropriate section
Message[302] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 8 : Register in operand not in bank 0. Ensure that bank bits are correct.
Error[152] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 8 : Executable code and data must be defined in an appropriate section
Message[302] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 9 : Register in operand not in bank 0. Ensure that bank bits are correct.
Error[152] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 9 : Executable code and data must be defined in an appropriate section
Error[152] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 10 : Executable code and data must be defined in an appropriate section
Error[152] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 11 : Executable code and data must be defined in an appropriate section
Error[152] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 12 : Executable code and data must be defined in an appropriate section
Error[152] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 13 : Executable code and data must be defined in an appropriate section
Halting build on first failure as requested.
----------------------------------------------------------------------
Release build of project `C:\Documents and Settings\Admin\Desktop\Group8\blinkingLED.mcp' failed.
Fri Jul 17 19:33:38 2009
----------------------------------------------------------------------
BUILD FAILED
 
Hi,
Your code reformatted.

You need to add more information in the header.

Code:
	list      p=16f84A         ; list directive to define processor
	#include <p16F84A.inc>        ; processor specific variable definitions
	errorlevel  -302 , -207             ; suppress message 302 from list file

	__config _XT_OSC & _CP_OFF & _PWRTE_OFF & _WDT_OFF


	ORG     0x00            ; processor reset vector
	goto    main              ; go to beginning of program
	

	ORG     0x004             ; interrupt vector location
	nop
	retfie                    ; return from interrupt

 
main:
	movlw	0x00
	bsf	STATUS, RP0
	movwf	TRISA
	movwf	TRISB
	bcf	STATUS, RP0
	movlw	0xFF
	movwf	PORTA
	movwf	PORTB

	end
 
Last edited:
thanks for replying.. but...

Hi,
Your code reformatted.

Code:
#INCLUDE P16F84A.INC 

	__config _XT_OSC & _CP_OFF & _PWRTE_OFF & _WDT_OFF

	movlw	0x00
	bsf	STATUS, RP0
	movwf	TRISA
	movwf	TRISB
	bcf	STATUS, RP0
	movlw	0xFF
	movwf	PORTA
	movwf	PORTB

	end

i already reformatted the codes, but still having the same result..:(
what should i do?is there any solution to resolve my problem?
 
i already reformatted the codes, but still having the same result..:(
what should i do?is there any solution to resolve my problem?

hi,
Did you copy the edited version of the program I posted, showing the Headers.???
 
s0 sorry... thank u s0 much!!:D

hi,
Did you copy the edited version of the program I posted, showing the Headers.???
----------------------------------------------------------------------
Release build of project `C:\Documents and Settings\Admin\Desktop\Group8\blinkingLED.mcp' started.
Fri Jul 17 20:12:07 2009
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F84A "blinkingLED.asm" /l"blinkingLED.lst" /e"blinkingLED.err" /o"blinkingLED.o"
Warning[205] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 1 : Found directive in column 1. (list)
Executing: "C:\Program Files\Microchip\MPASM Suite\mplink.exe" /p16F84A "blinkingLED.o" /z__MPLAB_BUILD=1 /o"blinkingLED.cof" /M"blinkingLED.map" /W
MPLINK 4.30.01, Linker
Copyright (c) 2009 Microchip Technology Inc.
Errors : 0

MP2HEX 4.30.01, COFF to HEX File Converter
Copyright (c) 2009 Microchip Technology Inc.
Errors : 0

Loaded C:\Documents and Settings\Admin\Desktop\Group8\blinkingLED.cof.
----------------------------------------------------------------------
Release build of project `C:\Documents and Settings\Admin\Desktop\Group8\blinkingLED.mcp' succeeded.
Fri Jul 17 20:12:08 2009
----------------------------------------------------------------------
BUILD SUCCEEDED


it really works!!your d best man!!:) thank you s0 much!!!!by the way, do i really need to type those headers everytime i try to create a program?
 
Yes, i already copied and pasted it on MPLAB, still, it didn't work... :(

hi,
Modified your program to flash the PORTA and B , on/off once per second.

It does work in Oshonsoft Sim OK.?


Code:
	list      p=16f84A         ; list directive to define processor
	#include <p16F84A.inc>        ; processor specific variable definitions
	errorlevel  -302 , -207             ; suppress message 302 from list file

	__config _XT_OSC & _CP_OFF & _PWRTE_OFF & _WDT_OFF

	
d1  	equ 0x20
d2 	equ 0x21
d3	equ 0x22


	ORG     0x00            ; processor reset vector
	goto    main              ; go to beginning of program
	

	ORG     0x004             ; interrupt vector location
	nop
	retfie                    ; return from interrupt

 
main:
	movlw	0x00
	bsf	STATUS, RP0
	movwf	TRISA
	movwf	TRISB
	bcf	STATUS, RP0

loop1:
	movlw	0xFF
	movwf	PORTA
	movwf	PORTB
	
	call Delay
	
	movlw	0x00
	movwf	PORTA
	movwf	PORTB

	call Delay

	goto loop1

Delay:
			;999997 cycles
	movlw	0x08
	movwf	d1
	movlw	0x2F
	movwf	d2
	movlw	0x03
	movwf	d3
Delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	$+2
	decfsz	d3, f
	goto	Delay_0
			;3 cycles
	goto	$+1
	return

	end

The header detail is VITAL in order for MPLAB to assemble your programs.

Make the Header part a text file, which you copy and paste.
NOTE: different PIC types require different Headers.

EDIT:
if you connect LED's to the PIC pins, use a low value resistor in series with the LED, say 330 ohms
 
Last edited:
Micro-wizard

hi,
Modified your program to flash the PORTA and B , on/off once per second.

It does work in Oshonsoft Sim OK.?


Code:
	list      p=16f84A         ; list directive to define processor
	#include <p16F84A.inc>        ; processor specific variable definitions
	errorlevel  -302 , -207             ; suppress message 302 from list file

	__config _XT_OSC & _CP_OFF & _PWRTE_OFF & _WDT_OFF

	
d1  	equ 0x20
d2 	equ 0x21
d3	equ 0x22


	ORG     0x00            ; processor reset vector
	goto    main              ; go to beginning of program
	

	ORG     0x004             ; interrupt vector location
	nop
	retfie                    ; return from interrupt

 
main:
	movlw	0x00
	bsf	STATUS, RP0
	movwf	TRISA
	movwf	TRISB
	bcf	STATUS, RP0

loop1:
	movlw	0xFF
	movwf	PORTA
	movwf	PORTB
	
	call Delay
	
	movlw	0x00
	movwf	PORTA
	movwf	PORTB

	call Delay

	goto loop1

Delay:
			;999997 cycles
	movlw	0x08
	movwf	d1
	movlw	0x2F
	movwf	d2
	movlw	0x03
	movwf	d3
Delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	$+2
	decfsz	d3, f
	goto	Delay_0
			;3 cycles
	goto	$+1
	return

	end

The header detail is VITAL in order for MPLAB to assemble your programs.

Make the Header part a text file, which you copy and paste.
NOTE: different PIC types require different Headers.

EDIT:
if you connect LED's to the PIC pins, use a low value resistor in series with the LED, say 330 ohms

w0w!!your a master!!hahaha!i just finished testing the result of the program that u gave me, its amazing!hahaha!i've really learned a lot from you!!thank you so much!!:)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top