Hi All,
I know this should be reallllly simple, but it is driving me insane...
could someone please add comments to make the understanding of the code so simple that even I could understand it...? I know it should be as simple as 1-1=0 but I am still struggling with it...
Delay
movlw 20h ; .32 in W register
movwf 21h ; placing .32 from W register into F (21h)
Loop1 ; subroutine name
decfsz 21h,1 ; decrementing 21h x 1 per loop (32,31,30....0 take 2 steps forward)
goto loop1 ; counting down from 32
decfsz 22h,1 ; count down from 35 x 255 times(32+3;including instruction cycles)
goto loop1
return
By my calculation this should countdown 8925 cycles which is still to fast to see with the eye (using 4mhz crystal), but the LEd is flashing (by my estimate) at 1/4 second...
thanks heaps
I know this should be reallllly simple, but it is driving me insane...
could someone please add comments to make the understanding of the code so simple that even I could understand it...? I know it should be as simple as 1-1=0 but I am still struggling with it...
Delay
movlw 20h ; .32 in W register
movwf 21h ; placing .32 from W register into F (21h)
Loop1 ; subroutine name
decfsz 21h,1 ; decrementing 21h x 1 per loop (32,31,30....0 take 2 steps forward)
goto loop1 ; counting down from 32
decfsz 22h,1 ; count down from 35 x 255 times(32+3;including instruction cycles)
goto loop1
return
By my calculation this should countdown 8925 cycles which is still to fast to see with the eye (using 4mhz crystal), but the LEd is flashing (by my estimate) at 1/4 second...
thanks heaps