Hello, I'm writing first time code assembly.
18F1320 trying to flash LED program hangs after movfw TRISA. Delay works fine, but won't go to the loop.
18F1320 trying to flash LED program hangs after movfw TRISA. Delay works fine, but won't go to the loop.
Code:
#include <p18F1320.inc>
;code protect disabled
CONFIG CP0=OFF
;Oscillator switch enabled, RC oscillator with OSC1 as I/O pin.
CONFIG OSC=INTIO1
;internal oscillator
CONFIG WDT=OFF
CONFIG LVP=OFF
cblock 100h ;start of general purpose registers
count1 ;used in delay routine
counta ;used in delay routine
countb ;used in delay routine
endc
movlw 0b01100010 ;4mhz
movwf OSCCON
main
movlw 0b11000000
movwf LATA
movwf TRISA
; (Hangs right here...)
Loop
movlw 0b00000001
movwf PORTA ;set bit 0 on
call Delay ;this waits for a while!
movlw 0b00000000
movwf PORTA
call Delay
goto Loop ;go back and do it again
Delay
movlw d'1' ;delay 250 ms (4 MHz clock)
movwf count1
d1 movlw d'1'
movwf counta
movlw d'1'
movwf countb
Delay_0
decfsz counta, f
goto $+2
decfsz countb, f
goto Delay_0
decfsz count1 ,f
goto d1
retlw 0x00
run
end