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.

Newbie question, cannot compile in MPLAB

Status
Not open for further replies.

Dunccc

New Member
Hi All

I'm just starting out with PIC programming and am working through a book called 'PIC In Practice' by D.W. Smith.

At the moment I am simply trying to get some code compiled to test out the very basics, however it would not compile. So I tried to compile just the header file, with the same results. I have not even got as far as attempting to blow the code into the PIC programmer so I believe this is simply an issue to do with the code or the IDE. The code I am trying to compile is as follows:

; HEADER84.ASM for 16F84. This sets PORTA as an INPUT
; and PORTB as an output
; The OPTION Register is set to /256 to give timing pulses of 1/32s
; 1 second and 0.5 second delays are included in the subroutine section.

; ************************

; EQUATES SECTION

TMR0 EQU 1
STATUS EQU 3
PORTA EQU 5
PORTB EQU 6
TRISA EQU 85H
TRISB EQU 86H
OPTION_R EQU 81H
ZEROBIT EQU 2
COUNT EQU 0CH

; ************************

LIST P=16F84
ORG 0
GOTO START

; ******************************

; Configuration Bits

_CONFIG H'4FF0'


; **********************

; SUBROUTINE SECTION

; 1 second delay

DELAY1 CLRF TMR0
LOOPA MOVF TMR0,W
SUBLW .32
BTFSS STATUS,
ZEROBIT
GOTO LOOPA
RETLW 0

; 0.5 second delay

DELAYP5 CLRF TMR0
LOOPB MOVF TMR0,W
SUBLW .16
BTFSS STATUS,
ZEROBIT
GOTO LOOPB
RETLW 0

; ************************

; CONFIGURATION SECTION

START BSF STATUS,5
MOVLW B'00011111'
MOVWF TRISA
MOVLW B'00000000'
MOVWF TRISB
MOVLW B'00000111'
MOVWF OPTION_R
BCF STATUS,5
CLRF PORTA
CLRF PORTB

; **************************
; Program starts now

END

(I have removed the comments and tried to format for easy reading, otherwise this is a direct copy/paste.)


The error message is as follows. All advice gratefully received!

----------------------------------------------------------------------
Debug build of project `C:\1diot stick and electronic misc\Duncsoft\HEADER84.disposable_mcp' started.
Preprocessor symbol `__DEBUG' is defined.
Wed Nov 26 18:20:43 2008
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\1diot stick and electronic misc\MicroChip\MPASM Suite\MPASMWIN.exe" /q /p16F84 "HEADER84.ASM" /l"HEADER84.lst" /e"HEADER84.err" /d__DEBUG=1
Warning[205] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 22 : Found directive in column 1. (LIST)
Warning[205] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 23 : Found directive in column 1. (ORG)
Warning[203] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 24 : Found opcode in column 1. (GOTO)
Error[122] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 30 : Illegal opcode (H)
Error[128] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 42 : Missing argument(s)
Warning[207] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 43 : Found label after column 1. (ZEROBIT)
Error[115] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 43 : Duplicate label ("ZEROBIT" or redefining symbol that cannot be redefined)
Error[128] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 52 : Missing argument(s)
Warning[207] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 53 : Found label after column 1. (ZEROBIT)
Error[115] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 53 : Duplicate label ("ZEROBIT" or redefining symbol that cannot be redefined)
Message[302] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 63 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 65 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 67 : Register in operand not in bank 0. Ensure that bank bits are correct.
Warning[205] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 78 : Found directive in column 1. (END)
Skipping link step. Not all sources built successfully.
----------------------------------------------------------------------
Debug build of project `C:\1diot stick and electronic misc\Duncsoft\HEADER84.disposable_mcp' failed.
Preprocessor symbol `__DEBUG' is defined.
Wed Nov 26 18:20:44 2008
----------------------------------------------------------------------
BUILD FAILED
 
Last edited:
hi,

To block the warning messages place
errorlevel -302, -207, 205

just above LIST in your program.

this will block these:
Message[302]
Warning[205]
Warning[207]

The ASM 22 is the line number in your code. eg: line #22

Place the CONFIG near the LIST


Compile and repost.:)

BTW: when you paste your code to the forum, select it and click the '#' symbol to keep the formatting.

;
Code:
 HEADER84.ASM for 16F84. This sets PORTA as an INPUT  
; and PORTB as an output  
; The OPTION Register is set to /256 to give timing pulses of 1/32s  
; 1 second and 0.5 second delays are included in the subroutine section.  

; ************************  

; EQUATES SECTION  

TMR0	equ	1
STATUS	equ	3
PORTA	equ	5
PORTB	equ	6
TRISA	equ	85H
TRISB	equ	86H
OPTION_R equ	81H
ZEROBIT	equ	2
COUNT	equ	0CH

; ************************  

	list	P=16F84
	org	0
	goto	START

; ******************************  

; Configuration Bits  

_CONFIG	H'4FF0'


; **********************  

; SUBROUTINE SECTION  

; 1 second delay  

DELAY1	clrf	TMR0
LOOPA	movf	TMR0,W
	sublw	.32
	btfss	STATUS,
ZEROBIT
	goto	LOOPA
	retlw	0

; 0.5 second delay  

DELAYP5	clrf	TMR0
LOOPB	movf	TMR0,W
	sublw	.16
	btfss	STATUS,
ZEROBIT
	goto	LOOPB
	retlw	0

; ************************  

; CONFIGURATION SECTION  

START	bsf	STATUS,5
	movlw	B'00011111'
	movwf	TRISA
	movlw	B'00000000'
	movwf	TRISB
	movlw	B'00000111'
	movwf	OPTION_R
	bcf	STATUS,5
	clrf	PORTA
	clrf	PORTB

; **************************  
; Program starts now  

	end
 
Last edited:
Thanks Eric. Recompiled and fixed the '4FF0' opcode to '3FF0', here is the result:

----------------------------------------------------------------------
Debug build of project `C:\1diot stick and electronic misc\Duncsoft\HEADER84.disposable_mcp' started.
Preprocessor symbol `__DEBUG' is defined.
Wed Nov 26 18:58:27 2008
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\1diot stick and electronic misc\MicroChip\MPASM Suite\MPASMWIN.exe" /q /p16F84 "HEADER84.ASM" /l"HEADER84.lst" /e"HEADER84.err" /d__DEBUG=1
Warning[205] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 21 : Found directive in column 1. (errorlevel)
Error[124] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 21 : Illegal argument (expected 0, 1, 2, or +|-<message number>)
Warning[205] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 23 : Found directive in column 1. (LIST)
Warning[205] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 24 : Found directive in column 1. (ORG)
Warning[203] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 25 : Found opcode in column 1. (GOTO)
Error[128] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 43 : Missing argument(s)
Error[115] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 44 : Duplicate label ("ZEROBIT" or redefining symbol that cannot be redefined)
Error[128] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 53 : Missing argument(s)
Error[115] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 54 : Duplicate label ("ZEROBIT" or redefining symbol that cannot be redefined)
Warning[205] C:\1DIOT STICK AND ELECTRONIC MISC\DUNCSOFT\HEADER84.ASM 79 : Found directive in column 1. (END)
Skipping link step. Not all sources built successfully.
----------------------------------------------------------------------
Debug build of project `C:\1diot stick and electronic misc\Duncsoft\HEADER84.disposable_mcp' failed.
Preprocessor symbol `__DEBUG' is defined.
Wed Nov 26 18:58:27 2008
----------------------------------------------------------------------
BUILD FAILED
 
hi,
Copy and paste this code into your MPLAB window, that is replace yours with this.:)
You were using ZEROBIT twice.!
Also LOOPB,,, Status there is no bit number.
fix the '4FF0' opcode to '3FF0',

EDIT:
#include <p16f84.inc>
if you add this include you dont need to define the Ports
TMR0 equ 1
STATUS equ 3
PORTA equ 5
PORTB equ 6
TRISA equ 85H
TRISB equ 86H
OPTION_R equ 81H


Code:
; HEADER84.ASM for 16F84. This sets PORTA as an INPUT  
; and PORTB as an output  
; The OPTION Register is set to /256 to give timing pulses of 1/32s  
; 1 second and 0.5 second delays are included in the subroutine section.  

; ************************  

; EQUATES SECTION  

TMR0	equ	1
STATUS	equ	3
PORTA	equ	5
PORTB	equ	6
TRISA	equ	85H
TRISB	equ	86H
OPTION_R equ	81H
ZEROBIT	equ	2
COUNT	equ	0CH

; ************************  
	errorlevel -302, -207, 205

	list	P=16F84
       #include <p16f84.inc>

; Configuration Bits  
	_CONFIG	H'3FF0'

	org	0
	goto	START

; ******************************  


; SUBROUTINE SECTION  

; 1 second delay  

DELAY1	clrf	TMR0
LOOPA	movf	TMR0,W
	sublw	.32
	btfss	STATUS,
ZEROBIT1
	goto	LOOPA
	retlw	0

; 0.5 second delay  

DELAYP5	clrf	TMR0
LOOPB	movf	TMR0,W
	sublw	.16
	btfss	STATUS,
ZEROBIT2
	goto	LOOPB
	retlw	0

; ************************  

; CONFIGURATION SECTION  

START	bsf	STATUS,5
	movlw	B'00011111'
	movwf	TRISA
	movlw	B'00000000'
	movwf	TRISB
	movlw	B'00000111'
	movwf	OPTION_R
	bcf	STATUS,5
	clrf	PORTA
	clrf	PORTB

; **************************  
; Program starts now  

	end


EDITED: updated this code.
 
Last edited:
hi Dunc,
Redited you code, copy and paste this, it does now compile in MPLAB
I have added 'Z' to the Status tests, change it to suit your code.

Let me know how it goes.:)

Code:
; HEADER84.ASM for 16F84. This sets PORTA as an INPUT  
; and PORTB as an output  
; The OPTION Register is set to /256 to give timing pulses of 1/32s  
; 1 second and 0.5 second delays are included in the subroutine section.  

; ************************  

; EQUATES SECTION  

TMR0	equ	1
STATUS	equ	3

; ************************  
	errorlevel -302, -207, -205

	list	P=16F84
       #include <p16f84.inc>

; Configuration Bits  
	__CONFIG	H'3FF0'


ZEROBIT	equ	2
COUNT	equ	0CH

	org	0
	goto	START

; ******************************  


; SUBROUTINE SECTION  

; 1 second delay  

DELAY1	clrf	TMR0
LOOPA	movf	TMR0,W
	sublw	.32
	btfss	STATUS,Z
ZEROBIT1
	goto	LOOPA
	retlw	0

; 0.5 second delay  

DELAYP5	clrf	TMR0
LOOPB	movf	TMR0,W
	sublw	.16
	btfss	STATUS,Z
ZEROBIT2
	goto	LOOPB
	retlw	0

; ************************  

; CONFIGURATION SECTION  

START	bsf	STATUS,5
	movlw	B'00011111'
	movwf	TRISA
	movlw	B'00000000'
	movwf	TRISB
	movlw	B'00000111'
	movwf	OPTION_REG
	bcf	STATUS,5
	clrf	PORTA
	clrf	PORTB

; **************************  
; Program starts now  

	end
 
I notice eric keep helping people. ERIC are you a teacher just wondering. You have a unique way of teaching so interesting :)
 
Problem with PIC 16 F84A assembly code

Hie, I need help for my project. Im doing Optical switching for protection.

Code:
  list      p=16F84A             ; list directive to define processor
    #include <p16F84a.inc>         ; processor specific variable definitions

    __CONFIG   _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC

; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.

;***** VARIABLE DEFINITIONS
w_temp        EQU     0x0C        ; variable used for context saving 
status_temp   EQU     0x0D        ; variable used for context saving
STATUS        equ     03h   
PORTA         equ     05h   
TRISA         equ     85h
PORTB         equ     06h
TRISB         equ     86h
COUNT1        equ     08h
COUNT2        equ     09h
PORT_RA       equ     0Ch
PORT_RB       equ     00h
RA3           equ     3
RA2           equ     2
RA1           equ     02h
RA0           equ     01h
ZERO          equ     10h
RB1           equ     02h
RB2           equ     04h
RB3           equ     08h


;**********************************************************************
RESET_VECTOR      CODE    0x0000  ; processor reset vector
        goto    start             ; go to beginning of program

ISR               CODE    0x0004  ; interrupt vector location

Interrupt:

        movwf  w_temp             ; save off current W register contents
        movf   STATUS,w           ; move status register into W register
        movwf  status_temp        ; save off contents of STATUS register

;  Place ISR Here

        movf   status_temp,w      ; retrieve copy of STATUS register
        movwf  STATUS             ; restore pre-isr STATUS register contents
        swapf  w_temp,f
        swapf  w_temp,w           ; restore pre-isr W register contents
        retfie                    ; return from interrupt

MAIN_PROGRAM    CODE 

start


; -------------------------------------------------------------------------------------------------------------------------------
;                                	PORTS SET-UP
; --------------------------------------------------------------------------------------------------------------------------------
              
                   		    org         		0                   ;reset vector to origin 0
                     		bsf         		STATUS,RP0          	;go to BANK 1
                     		movlw       	    PORT_RA           	;set RA2 and RA3 as input
                     		movwf       	    TRISA               ;move 04h to TRISA
                     		movlw       	    PORT_RB        	    ;set all RB ports as output
                     		movwf       	    TRISB               ;move to TRISB
							bcf         		STATUS,RP0       	    ;back to BANK 0
                     		

; --------------------------------------------------------------------------------------------------------------------------------
;                                  	PROGRAM STARTS
; --------------------------------------------------------------------------------------------------------------------------------

                     		call        		DELAY_2             ;delaying
                     		goto        	    SERVICE             ;switch to service for start 
                     
; --------------------------------------------------------------------------------------------------------------------------------
;                                	SWITCH TO SERVICE
; --------------------------------------------------------------------------------------------------------------------------------

        SERVICE     		movlw       	   RA1                  ;switching to service line
                     		movwf      	       PORTA               	;move to PORTA
                     		call        	   DELAY_20ms    	    ;20ms delay     
                     		movlw      	       ZERO                 ;output to RA1 is set to zero
                     		movwf      	       PORTA                ;move to PORTA
                     		goto        	   SERV_LED  	        ;call service mode LED indicator
        SERV_LED          	movlw       	   RB1                  ;service mode LED is lit
                     		movwf       	   PORTB              	;move to PORTB
                    	 	call        	   DELAY_2           	;delaying

; --------------------------------------------------------------------------------------------------------------------------------
;                                	CHECK SIGNAL AT RA2 
; --------------------------------------------------------------------------------------------------------------------------------

        CHECK_RA2           btfss      		   PORTA,RA2     	    ;if RA2 is 1, then skip one 
                     		goto        	   CHECK_RA2_3 	        ;check both inputs if RA2 is 0
                     		call       	       DELAY_2          	;delaying
                     		goto        	   CHECK_RA2     	    ;loop

; --------------------------------------------------------------------------------------------------------------------------------
;                                	CHECKING PORTS RA2 AND RA3
; --------------------------------------------------------------------------------------------------------------------------------

        CHECK_RA2_3        	btfsc       	   PORTA,RA2      	     ;if RA2 is 0, then skip one 
                     		goto       		   SERVICE           	 ;switch to service line
                     		btfsc       	   PORTA,RA3      	     ;if RA3 is 0, then skip one                   
                     		goto        	   PROTECTION   	     ;switch to protection
                     		goto        	   FAILED                ;call failed mode

; --------------------------------------------------------------------------------------------------------------------------------
;                                 	LED INDICATING THAT BOTH FIBERS HAVE FAILED (RB3)
; --------------------------------------------------------------------------------------------------------------------------------

        FAILED             	movlw        	   RB3                  ;Fiber failure LED lit
                    		movwf        	   PORTB                ;move to PORTB
                     		call         	   DELAY_1          	;delaying
                     		goto         	   CHECK_RA2_3	        ;loop 
                   
; --------------------------------------------------------------------------------------------------------------------------------
;                                	 SWITCH TO PROTECTION
; --------------------------------------------------------------------------------------------------------------------------------                                      
             
        PROTECTION       	movlw        	   RA0                  ;switching to protection line
                     		movwf        	   PORTA                ;move to PORTA                                        
                     		call         	   DELAY_20ms       	;20ms delay                                                       
                     		movlw        	   ZERO                	;output to RA0 is zero
                     		movwf       	   PORTA                ;move to PORTA
                     		goto         	   PROC_LED       	    ;call protection mode LED indicator
        PROC_LED       		movlw       	   RB2                  ;protection mode LED is lit
                     		movwf        	   PORTB                ;move to PORTB
                    		call         	   DELAY_1         	    ;delaying                    
                     		goto         	   CHECK_RA3            ;check RA3 input

; --------------------------------------------------------------------------------------------------------------------------------
;                                 	CHECK SIGNAL AT RA3 FOR SERVICE MODE
; --------------------------------------------------------------------------------------------------------------------------------

   		CHECK_RA3           btfss        	   PORTA,RA3      	    ;if RA3 is 1, then skip one 
                     		goto         	   CHECK_RA2_3	        ;check both inputs if RA3 is 0
                     		goto         	   CHECK_RA3        	;loop 

; --------------------------------------------------------------------------------------------------------------------------------
;                                  	DELAY_1 SUBROUTINE
; --------------------------------------------------------------------------------------------------------------------------------

        DELAY_1      
	    Loop1               decfsz        	   COUNT1,1
                     		goto          	   Loop1
                     		return          

; --------------------------------------------------------------------------------------------------------------------------------
;                                 	 DELAY_2 SUBROUTINE
; --------------------------------------------------------------------------------------------------------------------------------

        DELAY_2      
   
        Loop2               decfsz        	   COUNT1,1
                    		goto          	   Loop2
                     		decfsz        	   COUNT2,1
                    		goto        	   Loop2
                    		return         

; --------------------------------------------------------------------------------------------------------------------------------
;                                  	DELAY_20ms SUBROUTINE
;
; Delay = 0.02 seconds
; Clock frequency = 4 MHz
; Actual delay = 0.02 seconds = 20000 cycles
; Error = 0 %
;
; --------------------------------------------------------------------------------------------------------------------------------

        DELAY_20ms                                 				
        	         		movlw         	   0x9E		            ;19993 cycles
	                 	    movwf	      	   COUNT1
	                 	    movlw	       	   0x10
	                 	    movwf	       	   COUNT2
        Delay_0
	                 	    decfsz	       	   COUNT1,1
	                 	    goto	       	   $+2
	                 	    decfsz	       	   COUNT2,1
	                 	    goto	       	   Delay_0		        ;3 cycles                              		
                     		goto	     	   $+1
                     		nop			                            ;4 cycles (including call)
		                 	return

; --------------------------------------------------------------------------------------------------------------------------------
;                                         END PROGRAM
; --------------------------------------------------------------------------------------------------------------------------------

            			end

        goto $

        END                       ; directive 'end of program'


Below are the error message:
Code:
----------------------------------------------------------------------
Debug build of project `C:\Projects\MyProject2.mcp' started.
Preprocessor symbol `__DEBUG' is defined.
Thu Feb 05 08:11:35 2009
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\Projects\MyProject2.mcs".
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F84A "16F84ATMPO.ASM" /l"16F84ATMPO.lst" /e"16F84ATMPO.err" /o"16F84ATMPO.o" /d__DEBUG=1
Message[302] C:\PROJECTS\16F84ATMPO.ASM 102 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\PROJECTS\16F84ATMPO.ASM 104 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Warning[207] C:\PROJECTS\16F84ATMPO.ASM 119 : Found label after column 1. (SERVICE)
Warning[207] C:\PROJECTS\16F84ATMPO.ASM 125 : Found label after column 1. (SERV_LED)
Warning[207] C:\PROJECTS\16F84ATMPO.ASM 133 : Found label after column 1. (CHECK_RA2)
Warning[207] C:\PROJECTS\16F84ATMPO.ASM 142 : Found label after column 1. (CHECK_RA2_3)
Warning[207] C:\PROJECTS\16F84ATMPO.ASM 152 : Found label after column 1. (FAILED)
Warning[207] C:\PROJECTS\16F84ATMPO.ASM 161 : Found label after column 1. (PROTECTION)
Warning[207] C:\PROJECTS\16F84ATMPO.ASM 167 : Found label after column 1. (PROC_LED)
Warning[207] C:\PROJECTS\16F84ATMPO.ASM 176 : Found label after column 1. (CHECK_RA3)
Warning[207] C:\PROJECTS\16F84ATMPO.ASM 184 : Found label after column 1. (DELAY_1)
Warning[207] C:\PROJECTS\16F84ATMPO.ASM 185 : Found label after column 1. (Loop1)
Warning[207] C:\PROJECTS\16F84ATMPO.ASM 193 : Found label after column 1. (DELAY_2)
Warning[207] C:\PROJECTS\16F84ATMPO.ASM 195 : Found label after column 1. (Loop2)
Warning[207] C:\PROJECTS\16F84ATMPO.ASM 211 : Found label after column 1. (DELAY_20ms)
Warning[207] C:\PROJECTS\16F84ATMPO.ASM 216 : Found label after column 1. (Delay_0)
Executing: "C:\Program Files\Microchip\MPASM Suite\mplink.exe" "16f84a.lkr" "16F84ATMPO.o" /u_DEBUG /z__MPLAB_BUILD=1 /z__MPLAB_DEBUG=1 /o"MyProject2.cof" /M"MyProject2.map" /W
MPLINK 4.20, Linker
Copyright (c) 2008 Microchip Technology Inc.
Error - section 'ISR' can not fit the absolute section. Section 'ISR' start=0x00000004, length=0x00000010
Errors    : 1

Link step failed.
----------------------------------------------------------------------
Debug build of project `C:\Projects\MyProject2.mcp' failed.
Preprocessor symbol `__DEBUG' is defined.
Thu Feb 05 08:11:39 2009
----------------------------------------------------------------------
BUILD FAILED

can somebody help me? thanks
 
All your errors are caused by you having white space at the beginning of your lines,

Change
Code:
        DELAY_20ms                                 				
        	         		movlw         	   0x9E		            ;19993 cycles
	                 	    movwf	      	   COUNT1
	                 	    movlw	       	   0x10
	                 	    movwf	       	   COUNT2
        Delay_0
	                 	    decfsz	       	   COUNT1,1
	                 	    goto	       	   $+2
	                 	    decfsz	       	   COUNT2,1
	                 	    goto	       	   Delay_0		        ;3 cycles                              		
                     		goto	     	   $+1
                     		nop			                            ;4 cycles (including call)
		                 	return

To

Code:
DELAY_20ms 
		movlw	0x9E		;19993 cycles
		movwf	COUNT1
		movlw	0x10
		movwf	COUNT2
Delay_0
		decfsz	COUNT1,1
		goto	$+2
		decfsz	COUNT2,1
		goto	Delay_0		;3 cycles                              
		goto	$+1
		nop			;4 cycles (including call)
		return

Labels have to be in the leftmost column.

Mike.
 
All your errors are caused by you having white space at the beginning of your lines,

Change
Code:
        DELAY_20ms                                 				
        	         		movlw         	   0x9E		            ;19993 cycles
	                 	    movwf	      	   COUNT1
	                 	    movlw	       	   0x10
	                 	    movwf	       	   COUNT2
        Delay_0
	                 	    decfsz	       	   COUNT1,1
	                 	    goto	       	   $+2
	                 	    decfsz	       	   COUNT2,1
	                 	    goto	       	   Delay_0		        ;3 cycles                              		
                     		goto	     	   $+1
                     		nop			                            ;4 cycles (including call)
		                 	return

To

Code:
DELAY_20ms 
		movlw	0x9E		;19993 cycles
		movwf	COUNT1
		movlw	0x10
		movwf	COUNT2
Delay_0
		decfsz	COUNT1,1
		goto	$+2
		decfsz	COUNT2,1
		goto	Delay_0		;3 cycles                              
		goto	$+1
		nop			;4 cycles (including call)
		return

Labels have to be in the leftmost column.

Mike.



thanks.

How about this error?

Code:
MPLINK 4.20, Linker
Copyright (c) 2008 Microchip Technology Inc.
Error - section 'ISR' can not fit the absolute section. Section 'ISR' start=0x00000004, length=0x00000010
Errors    : 1

Link step failed.

I need to change CODE to ORG right?
but error missing argument at MAIN_PROGRAM ORG after changed to

Code:
RESET_VECTOR      ORG    0x0000  ; processor reset vector
        goto    start             ; go to beginning of program

ISR               ORG    0x0004  ; interrupt vector location

Interrupt:

        movwf  w_temp             ; save off current W register contents
        movf   STATUS,w           ; move status register into W register
        movwf  status_temp        ; save off contents of STATUS register

;  Place ISR Here

        movf   status_temp,w      ; retrieve copy of STATUS register
        movwf  STATUS             ; restore pre-isr STATUS register contents
        swapf  w_temp,f
        swapf  w_temp,w           ; restore pre-isr W register contents
        retfie                    ; return from interrupt

MAIN_PROGRAM    ORG
 
thanks.

How about this error?

Code:
MPLINK 4.20, Linker
Copyright (c) 2008 Microchip Technology Inc.
Error - section 'ISR' can not fit the absolute section. Section 'ISR' start=0x00000004, length=0x00000010
Errors    : 1

Link step failed.

I need to change CODE to ORG right?
but error missing argument at MAIN_PROGRAM ORG after changed to

Code:
RESET_VECTOR      ORG    0x0000  ; processor reset vector
        goto    start             ; go to beginning of program

ISR               ORG    0x0004  ; interrupt vector location

Interrupt:

        movwf  w_temp             ; save off current W register contents
        movf   STATUS,w           ; move status register into W register
        movwf  status_temp        ; save off contents of STATUS register

;  Place ISR Here

        movf   status_temp,w      ; retrieve copy of STATUS register
        movwf  STATUS             ; restore pre-isr STATUS register contents
        swapf  w_temp,f
        swapf  w_temp,w           ; restore pre-isr W register contents
        retfie                    ; return from interrupt

MAIN_PROGRAM    ORG

That is the simplest way to fix it. You will also need to remove any linker script that you have. You only need the first two orgs, the one on main is not required.

Mike.
 
If i remove the ORG at main,

another error occur:

Code:
----------------------------------------------------------------------
Debug build of project `C:\Projects\MyProject2.mcp' started.
Preprocessor symbol `__DEBUG' is defined.
Thu Feb 05 14:14:42 2009
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F84A "16F84ATMPO.ASM" /l"16F84ATMPO.lst" /e"16F84ATMPO.err" /o"16F84ATMPO.o" /d__DEBUG=1
Message[302] C:\PROJECTS\16F84ATMPO.ASM 103 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\PROJECTS\16F84ATMPO.ASM 105 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Executing: "C:\Program Files\Microchip\MPASM Suite\mplink.exe" "16f84a.lkr" "16F84ATMPO.o" /u_DEBUG /z__MPLAB_BUILD=1 /z__MPLAB_DEBUG=1 /o"MyProject2.cof" /M"MyProject2.map" /W
MPLINK 4.20, Linker
Copyright (c) 2008 Microchip Technology Inc.
Error - section '.org_2' can not fit the absolute section. Section '.org_2' start=0x00000000, length=0x0000007c
Errors    : 1

Link step failed.
----------------------------------------------------------------------
Debug build of project `C:\Projects\MyProject2.mcp' failed.
Preprocessor symbol `__DEBUG' is defined.
Thu Feb 05 14:14:43 2009
----------------------------------------------------------------------
BUILD FAILED

if i remove the link script and that ORG, more errors:

Code:
----------------------------------------------------------------------
Debug build of project `C:\Projects\MyProject2.mcp' started.
Preprocessor symbol `__DEBUG' is defined.
Thu Feb 05 14:16:39 2009
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\Projects\16F84ATMPO.o".
Clean: Deleted file "C:\Projects\16F84ATMPO.lst".
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F84A "16F84ATMPO.ASM" /l"16F84ATMPO.lst" /e"16F84ATMPO.err" /d__DEBUG=1
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 101 : Overwriting previous address contents (0000)
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 101 : Overwriting previous address contents (0000)
Message[302] C:\PROJECTS\16F84ATMPO.ASM 103 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\PROJECTS\16F84ATMPO.ASM 105 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 105 : Overwriting previous address contents (0004)
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 105 : Overwriting previous address contents (0004)
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 106 : Overwriting previous address contents (0005)
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 106 : Overwriting previous address contents (0005)
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 113 : Overwriting previous address contents (0006)
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 113 : Overwriting previous address contents (0006)
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 114 : Overwriting previous address contents (0007)
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 114 : Overwriting previous address contents (0007)
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 120 : Overwriting previous address contents (0008)
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 120 : Overwriting previous address contents (0008)
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 121 : Overwriting previous address contents (0009)
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 121 : Overwriting previous address contents (0009)
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 122 : Overwriting previous address contents (000A)
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 122 : Overwriting previous address contents (000A)
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 123 : Overwriting previous address contents (000B)
Error[118]   C:\PROJECTS\16F84ATMPO.ASM 123 : Overwriting previous address contents (000B)
Halting build on first failure as requested.
----------------------------------------------------------------------
Debug build of project `C:\Projects\MyProject2.mcp' failed.
Preprocessor symbol `__DEBUG' is defined.
Thu Feb 05 14:16:40 2009
----------------------------------------------------------------------
BUILD FAILED
 
That is because you replaced it with CODE or you didn't delete the linker script.

If it still doesn't work post your code again.

Mike.
 
Hi abc1122,

BUILD SUCCEEDED with MPLAB 8.10 and maybe other version, if you remove red line bellow.

Code:
******
******
MAIN_PROGRAM    CODE 

start


; -------------------------------------------------------------------------------------------------------------------------------
;                                	PORTS SET-UP
; --------------------------------------------------------------------------------------------------------------------------------
              
    [COLOR="Red"]; remove this line [/COLOR]    org		0                   ;reset vector to origin 0
                     		bsf         		STATUS,RP0          	;go to BANK 1
                     		movlw       	    PORT_RA           	;set RA2 and RA3 as input
                     		movwf       	    TRISA               ;move 04h to TRISA
                     		movlw       	    PORT_RB        	    ;set all RB ports as output
*****
*****
 
Hi abc1122,

BUILD SUCCEEDED with MPLAB 8.10 and maybe other version, if you remove red line bellow.

Code:
******
******
MAIN_PROGRAM    CODE 

start


; -------------------------------------------------------------------------------------------------------------------------------
;                                	PORTS SET-UP
; --------------------------------------------------------------------------------------------------------------------------------
              
    [COLOR="Red"]; remove this line [/COLOR]    org		0                   ;reset vector to origin 0
                     		bsf         		STATUS,RP0          	;go to BANK 1
                     		movlw       	    PORT_RA           	;set RA2 and RA3 as input
                     		movwf       	    TRISA               ;move 04h to TRISA
                     		movlw       	    PORT_RB        	    ;set all RB ports as output
*****
*****

Well spotted, I missed that sneaky org.

Mike.
 
Sorry to high jack this thread
but on compiling in MPLab I get this error,
Code:
MPLINK 4.20, Linker
Copyright (c) 2008 Microchip Technology Inc.
Error - section 'MAIN_PROGRAM' can not fit the section. Section 'MAIN_PROGRAM' length=0x0000133a
Errors    : 1

Link step failed.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top