HC908QY4A  A very peculiar bug

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

HC908QY4A  A very peculiar bug

2,033 次查看
bigmac
Specialist III
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.
 
Regards,
Mac
 
标签 (1)
0 项奖励
回复
3 回复数

721 次查看
JimDon
Senior Contributor III
The only difference I see between DEC and DBNZ is that DEC affects the conditions code and DBNZ does not.


You comments says:
; On exit, ZF = 1 if timeout occurred.

So perhaps this is it...



0 项奖励
回复

721 次查看
bigmac
Specialist III
Hello Tony P and Jim D,
 
Thank you for pointing out the problem - I think a question of not seeing the wood for the trees.  Yes I do test the Z-flag to determine whether timout had occurred, or not.
 
Regards,
Mac
 
0 项奖励
回复

721 次查看
tonyp
Senior Contributor II
Your code says:

; On exit, ZF = 1 if timeout occurred.

DBNZ instructions do NOT affect the Z flag.  Could this be it?



0 项奖励
回复