WTF? Am I crazy?


Results 1 to 6 of 6

Threaded View

  1. #1
    RichardBowser's Avatar
    RichardBowser Guest

    Question WTF? Am I crazy?

    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?
    Last edited by RichardBowser; - 6th July 2006 at 21:53.

Similar Threads

  1. 12f675 making me a crazy person
    By Meriachee in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 16th September 2009, 21:55
  2. 18f4550 usb problem.. so im getting crazy..
    By MeSaKu in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th May 2009, 22:03
  3. Using portb as inputs PIC goes crazy
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th November 2005, 14:15
  4. My Code get crazy after i add interrupt
    By jetpr in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th May 2005, 04:43

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts