HC908QY4A  A very peculiar bug

Discussion created by bigmac on Jul 24, 2008
Latest reply on Jul 24, 2008 by bigmac
Hello all,
Background -
I am using a QY4A device, in conjunction with assembly code, to decode an on-off keyed (OOK) signal that is output from a wireless receiver.  This signal is connected to the external IRQ pin.  The decode algorithm makes use of a pair of sub-routines that will exit when a change of state occurs, or after a timeout period has elapsed.  The sub-routines are designed to ignore short noise pulses from the receiver.
The assembly code for one of the sub-routines is attached.  The other sub-routine is similar, except that it handles signal transitions of the opposite polarity.  The attached code operates as expected, and the decoding process is successful.
However, when I attempted to replace the pair of instructions
    DEC  1,SP
    BNE  WL0
with the single instruction
    DBNZ  1,SP,WL0
the decoding process failed.  I tried preceeding the line with a couple of NOPs, so as to retain the same number of cycles, but to no avail.  It is as though the branch is always taken, or never taken - I can't be certain which one.  Full chip simulation gives the expected result.
I wonder if anyone else has experienced a similar problem.  It has certainly involved some head scratching for the last few days - perhaps I am missing something obvious.