Hallo
I am busy trying out the PIC KIT 1 to get familiar with these micros and ASM language. I ammended tutorial 2 that came with the evaluation PIC KIT 1. Its an example of a state machine. The tutorial allows one to press a button on the board and after each button press, an one LED out of eight lights up. After each button press, the next LED lights up and so forth.
So basically I removed the button press detection in the SW and I decided to add a nested loop as shown below (extracted portion of the code. The question will follow below):
;************************** VARIABLE DEFINITIONS ******************************
cblock 0x20
Counter1
Counter2
Counter3
endc
;************
;Init
;************
clrf Counter1
clrf Counter2
clrf Counter3
;***************************************************************************
; State_Machine
;
;***************************************************************************
State_Machine
clrwdt ; clear Watch Dog Timer
comf Counter1,f ;set counter 1 to all 1's i.e. FFh. The letter f=1 in the p12f629.inc file
comf Counter2,f
comf Counter3,f
Loop1 decfsz Counter1,f
;Loop2 decfsz Counter2,f
; Loop3 decfsz Counter3,f
; goto Loop3
; goto Loop2
goto Loop1
Question:
Can I do a delay in the form of a nested Loop1, Loop2 and Loop3 as shown above? When I inserted this into the code, it built ok but the delay does not work when I program it into the pic 12F675.
When I only use Loop1 (i.e. with Loop2 and Loop3 disabled by the semicolon ";" all 8 LED's light.
So the only conclusion I can make is that the Loop1 delay is to short and as a result the LED's are switching at a very fast pace....the result of which is that they appear to all be on continuously
The moment I activate Loop2 , all LED's are off and there is no sequential LED ON /OFF sequence.
I suspect that the nested loop is a violation in ASM programming?