Jag får följande meddelande:
"MPLINK 4.11, Linker
Copyright (c) 2007 Microchip Technology Inc.
Error - file 'G:\PIC\ASM\PIC18LF1320\UV-box\uvbox.o', section 'DLY_CODE', Symbol '_DLY_CODE_0036' is not word-aligned.
It can not be used as the target of a call or goto instruction.
Errors : 1"
En titt på delay-koden:
Kod: Markera allt
;Delay-rutiner
DLY_VARS UDATA_ACS
d1 RES 1
d2 RES 1
d3 RES 1
DLY_CODE CODE
;Delay 1 sek.
Delay_1s
movlw 0x5A
movwf d1
movlw 0xCD
movwf d2
movlw 0x16
movwf d3
Delay_1s_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_1s_0
nop
return
; Delay 5 ms.
Delay_5ms
movlw 0x0E
movwf d1
movlw 0x28
movwf d2
Delay_5ms_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_5ms_0
goto $+1
nop
return
; Delay 1 us.
Delay_1us
movlw 0xC6
movwf d1
movlw 0x01
movwf d2
Delay_1us_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_1us_0
goto $+1
nop
return
Jag har testat att byta "goto" till "bra". Har även testat att allokera variablerna till olika delar av minnet, men inget av det har löst problemet.
Men på den här sajten så hittade jag detta:
"For PIC18, this delay routine will need a little modification to work properly.. the goto $+1 within the delay loops that sometimes appears needs to be changed to goto $+6, since each program word is 2 bytes, and goto is a 4 byte instruction. Also, at the end sometimes goto $+1 is used as a 2 cycle delay, need to use goto $+4 to skip over the whole goto."
Jag får inte ihop matten där riktigt, varför $+1 ska ändras till $+6 och $+1 ska ändras till $+4.
Det fungerar när jag ändrar, men känns just nu lite för osäkert att bara ändra utan att till 100% hänga med på varför just $+6 och $+4 fungerar.
Någon som kan räta ut min rynkade panna?

edit: Hoppsan.. 02:40.. Skulle ha lagt mig för tre timmar sedan, men det är lätt att fastna när man har kul.
