ISRRX.OnData stops firing
Posted: Tue Jan 20, 2015 5:55 am
Hi gurus,
I've only just recently inherited a project to debug and am having problems getting the code - as delivered - to function correctly.
I've purchased the most recent Swordfish compiler as the client doesn't have access to it - the previous contractor owned the copy. I can only assume it's an older revision as the code didn't compile out-of-the-box on my machine, and I've been assured that it's the latest source. The errors pertained to equality comparisons of a Byte variable to character literals - which I've since fixed.
Anyway, to the issue at hand. The code uses the ISRRX module, and no other interrupts. It initialises the OnData callback and appears to function correctly for approximately 20 seconds on average, then stops firing. Seems to be no obvious pattern or packet type.
I've added code to flash a LED in the OnData subroutine and as expected, it flashes for the initial 20s or so, and then stops flashing, coinciding with the communications failure.
Can anyone suggest why I would get this behaviour? I haven't come across any code that enables/disables the interrupt elsewhere in the code, so I can't see why this would be happening suddenly. The hardware came pre-programmed with the old firmware (CP0=ON, so I can't re-read) and it didn't have this issue. I can only assume there's something different in the latest compiler and/or ISRRX module that older versions didn't have to worry about?
I'm an embedded software engineer but with a total of 1 day's experience programming PICs, let-alone Swordfish BASIC, I'm at a loss where to even start looking.
EDIT: I've just noticed that the code is calling USART.Write within the OnData callback. Is that kosher? FTR the code is awful!![Crying or Very sad :cry:](./images/smilies/icon_cry.gif)
EDIT2: I've just noticed that it doesn't appear to be consuming bytes. OnData simply references ISRRX.DataChar and doesn't call any read routines... could it be a buffer over-run that is preventing OnData being called again?
I've only just recently inherited a project to debug and am having problems getting the code - as delivered - to function correctly.
I've purchased the most recent Swordfish compiler as the client doesn't have access to it - the previous contractor owned the copy. I can only assume it's an older revision as the code didn't compile out-of-the-box on my machine, and I've been assured that it's the latest source. The errors pertained to equality comparisons of a Byte variable to character literals - which I've since fixed.
Anyway, to the issue at hand. The code uses the ISRRX module, and no other interrupts. It initialises the OnData callback and appears to function correctly for approximately 20 seconds on average, then stops firing. Seems to be no obvious pattern or packet type.
I've added code to flash a LED in the OnData subroutine and as expected, it flashes for the initial 20s or so, and then stops flashing, coinciding with the communications failure.
Can anyone suggest why I would get this behaviour? I haven't come across any code that enables/disables the interrupt elsewhere in the code, so I can't see why this would be happening suddenly. The hardware came pre-programmed with the old firmware (CP0=ON, so I can't re-read) and it didn't have this issue. I can only assume there's something different in the latest compiler and/or ISRRX module that older versions didn't have to worry about?
I'm an embedded software engineer but with a total of 1 day's experience programming PICs, let-alone Swordfish BASIC, I'm at a loss where to even start looking.
EDIT: I've just noticed that the code is calling USART.Write within the OnData callback. Is that kosher? FTR the code is awful!
![Crying or Very sad :cry:](./images/smilies/icon_cry.gif)
EDIT2: I've just noticed that it doesn't appear to be consuming bytes. OnData simply references ISRRX.DataChar and doesn't call any read routines... could it be a buffer over-run that is preventing OnData being called again?