tgraz34 wrote:I thought maybe it had something to do with the decfsz command
can you please explain why it still looks the same?
Also, how come when i added this code, it doesnt look like led stays on for any longer than it did before?
sorry for the late reply, have been away
The reason that it performs pretty much exactly the same is because the decfsz command will FIRST decrement from the variable and THEN check if it zero. So think about this:
If we have this as our delay
movlw d'255'
movwf delay_0
movwf delay_1
delay_loop
decfsz delay_0, f
goto delay_loop
decfsz delay_1, f
goto delay_loop
return
you can see that we load the two variables with 255, then we decrement delay_0 by one - so it goes to 254. It is not zero yet so we goto the delay_loop label.
so when delay_0 eventually gets to 1 and we then use the decfsz command, we decrement by one and then check if it is zero. since it will now be zero we don't loop but we goto the command just underneath which is decfsz delay_1 which means it now goes to 254. since delay_1 is not zero, we goto the delay_loop label again. Now just underneath the delay_loop label is again decfsz delay_0, f
remember what what is delay_0? it was zero! because we had already counted down from 255 to zero with this one. but now that we decrement and then check if it zero we actually end up at 255 again (because taking one away from zero will loop you back around to 255)
so in actual fact, we are counting down from 255, 255 times.
as for this code not actually doing anything:
it is because you aren't also adding this to your loop routine:
you are loading it up, but then not using it.