Re: PIC16F628A Error: section '.org_0' can not fit the absolute section

I am a newbie trying to write a simple program using MPlab IDE using a P16F628A.

When I click on Build All the assempler produces this error message:

"Error - section '.org_0' can not fit the absolute section. Section '.org_0' start=0x00000000, length=0x0000003e Errors : 1"

Can someone please tell me what is meant by "cannot fit the absolute section" and how to correct it.

Thanks in anticipation of some help.

Syd

Reply to
Syd
Loading thread data ...

I dont recognise that section .org_0

is it one you created ? what does it have in it ?

looks like its the start of your code, like the interrupt vector table, maybe it has the wrong attributes or something.

Colin =^.^=

Reply to
colin

I would need to see the rest of the code to see how you have it set up. You may have a problem with a relocatable section, or your code at origin 0 is overlapping an interrupt vector (usually located at 0x04 or 0x08).

If you use absolute addresses for code, you should use a jump instruction at ORG 0 to branch to another absolute location past the interrupt vectors.

Using relocatable code, do it like this:

; Data can be located in a specific address space, ; or leave off the address to allow the linker to locate it

group1 UDATA 0x80 a_data res 1 ;0x80 b_data res 1 c_data res 1

;****************** Reset vector ********************

; This code will start executing when a reset occurs. RST CODE 0x0000 goto Main ;go to start of main code

;**************************************************** ; The linker is forced to locate this code at the specified address

INTVEC CODE 0x0004 ; interrupt vector location goto Isr

;************** Interrupt Processing **************** ; This code can be relocated anywhere by the linker CODE Isr: 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

; Do Interrupt processing EndIsr 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

;************* Start of Program **************** Main ; Add your main code here ;************* End of Program **************** END

Reply to
Paul E. Schoen

Hi Paul

My Code partly borrowed from others programming an 16F84A and part from MPLAB IDE V7.62 follows:

org 0x0000 ; Origin start address for 16f628 ;RESET_VECTOR CODE 0x0000 ; processor reset vector ********** ; goto Loop

; ****Disable the Comparitors using CMCON Register to make I/O Pins available for general use**** movlw 0x07 ; Place 07 in the w register movwf CMCON

Loop ; Label

; ************Setup Ports A & B ************ bsf STATUS, RP0 ; Set Status Bit=1 to select Bank 1 movlw b'00000000' ; Put Bin value into w register movwf TRISB ; Set Port B All as Outputs movwf TRISA ; Set Port A All as Outputs bcf STATUS, RP0 ; Set Status Bit=0 to select Bank 0 ; Main ; Start of program ay Label Main

; ********* Switching Port Pins HI = On ***************** movlw 0xff ; ff = 11111111 movwf PORTA ; Set all PORTA pins Outputs = Hi movlw PORTB ; Set all PORTB pins Outputs = Hi

; ***** Waist 2msecs to ensure ports go fully Hi and then use Delay Routine to keep Hi for a while ***** NOP ; 1 Microsec with 4MHz Osc NOP ; 1 Microsec with 4MHz Osc call Delay ; Increase On time

; ******* Switching All PORTA & PORTB pins 0 = Lo = Off

***************** movlw 0x00 ; 00 = 00000000 movwf PORTA ; Set all PORTA pins Outputs = Lo movlw PORTB ; Set all PORTA pins Outputs = Lo call Delay ; Increase Off time using delay subroutine

goto Loop ; Go back to loop label an do again

; For 250ms delay subroutine (4MHz Clock) Store values in variables (count1 = 250, count2 = 199, count3 = 1) Delay movlw d'250' ; Place decimal 250 into w register movwf count1 ; Store in count1 variable

dl movlw 0xC7 ; Place decimal 199 = Hex C7 into w register movwf count2 ; Store in count2 variable

movlw 0x01 ; Place decimal 1 = Hex 01 into w register movwf count3 ; Store in count3 variable

Delay_0 decfsz count2,f ; Decrement count2 (199) & skip next line if count2 = 0 goto $+2 ; Skip to 2 lines forward (goto d1) decfsz count3,f ; Decrement count3 goto Delay_0 ; Skip the next line if count3 = 0 decfsz count1,f ; Decrement count1 (250) & skip next line if count2 = 0 goto dl ; Go back to dl retlw 0x00 ; Return from subroutine with 0 in w register

end ; End of Program

Reply to
Syd

Hi Colin

My Code partly borrowed from others programming an 16F84A and part from MPLAB IDE V7.62 follows:

org 0x0000 ; Origin start address for 16f628 ;RESET_VECTOR CODE 0x0000 ; processor reset vector ********** ; goto Loop

; ****Disable the Comparitors using CMCON Register to make I/O Pins available for general use**** movlw 0x07 ; Place 07 in the w register movwf CMCON

Loop ; Label

; ************Setup Ports A & B ************ bsf STATUS, RP0 ; Set Status Bit=1 to select Bank 1 movlw b'00000000' ; Put Bin value into w register movwf TRISB ; Set Port B All as Outputs movwf TRISA ; Set Port A All as Outputs bcf STATUS, RP0 ; Set Status Bit=0 to select Bank 0 ; Main ; Start of program ay Label Main

; ********* Switching Port Pins HI = On ***************** movlw 0xff ; ff = 11111111 movwf PORTA ; Set all PORTA pins Outputs = Hi movlw PORTB ; Set all PORTB pins Outputs = Hi

; ***** Waist 2msecs to ensure ports go fully Hi and then use Delay Routine to keep Hi for a while ***** NOP ; 1 Microsec with 4MHz Osc NOP ; 1 Microsec with 4MHz Osc call Delay ; Increase On time

; ******* Switching All PORTA & PORTB pins 0 = Lo = Off

***************** movlw 0x00 ; 00 = 00000000 movwf PORTA ; Set all PORTA pins Outputs = Lo movlw PORTB ; Set all PORTA pins Outputs = Lo call Delay ; Increase Off time using delay subroutine

goto Loop ; Go back to loop label an do again

; For 250ms delay subroutine (4MHz Clock) Store values in variables (count1 = 250, count2 = 199, count3 = 1) Delay movlw d'250' ; Place decimal 250 into w register movwf count1 ; Store in count1 variable

dl movlw 0xC7 ; Place decimal 199 = Hex C7 into w register movwf count2 ; Store in count2 variable

movlw 0x01 ; Place decimal 1 = Hex 01 into w register movwf count3 ; Store in count3 variable

Delay_0 decfsz count2,f ; Decrement count2 (199) & skip next line if count2 = 0 goto $+2 ; Skip to 2 lines forward (goto d1) decfsz count3,f ; Decrement count3 goto Delay_0 ; Skip the next line if count3 = 0 decfsz count1,f ; Decrement count1 (250) & skip next line if count2 = 0 goto dl ; Go back to dl retlw 0x00 ; Return from subroutine with 0 in w register

end ; End of Program

Reply to
Syd

goto Main ;***** At reset, you should have a jump to Main, for initialization org 0x0020 Main: ;This will be your program entry point, past the interrupt table

Put your port initializations here

Loop: ;Here is where the loop should be located

See comments above. You might also check the settings on the IDE. I think you can switch from relocatable to absolute code which does not require the linker. Just some thoughts. Good luck,

Paul

Reply to
Paul E. Schoen

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.