I have attached my code for blinking the LED connected to the RA3 port. However, I have tried various delay codes with no avail. I have written my own code and yet it fails. It seems the problem is in the loop lines. Please see my project attached. Help...
Main ;BSF PORTA,2 ; Turn on LED connected to RA2
BSF PORTA,3
;BCF PORTA,2
;BCF PORTA,3
Loop movlw b'11111111'
movwf countw
decfsz countw, 1
goto Loop
goto Main
That is wrong because the LED is only turned on. Even if it turned off by removing the semicolon, the LED would only be on for a very short time.
The Loop is also incorrect because the register 'countw' reset to b'11111111' each time round so it never gets to zero.
It should be something like:-
Code:
Main BSF PORTA,3 ;turn on LED
movlw b'11111111'
movwf countw
Loop decfsz countw, 1 ;loop only goes back to here
goto Loop
BCF PORTA,3 ;turn off LED
movlw b'11111111'
movwf countw
loop2 decfsz countw, 1
goto Loop2
goto Main
Your loop is loading 255 and counting down from there. It is too short of a delay at the moment even with two loops. You'll have to lengthen the delay in order to get it to blink. Search for 'SPI code help' the program there has an example delay code for a 8 Mhz chip. Also search for 'Assembly delay (16F88)' It has a good explanaton of delay code and a site to calculate delays.