Hi everyone
I am really puzzled, though I suspect my difficulty has a TRIVIAL solution. I am trying to insert a parameterized iteration of do-nothings to allow simple tuning of application software to match target hardware. It SHOULD be easy: I declare “TtW” CON $n” for (Time to Wait). Then here’s what I try:
movlw _TtW,0
movwf _WaitCt,0
movlw _TtW
movwf _WaitCt,0
decf _WaitCt,F,0
btfss STATUS,Z ;normally WaitCt <> 0, so Z is clear
goto $-2
Only it doesn’t work. If TtW = 1, it immediately falls through. If TtW = 2, then it hangs infinitely. If I correct that by inserting a second “decf” then WaitCt = 0 when it reaches the bit test and then it just falls through. Yet I’ve seen similar code used in MANY known working routines. But it ONLY skips hanging if TtW = the nunber of "decf" instructions before the "btfss".
Why will the above not just keep on decrementing WaitCt until it reaches a terminal 0?
Bookmarks