seidleroni
Joined: 08 Sep 2008 Posts: 21
|
CAN Receive interrupt problem - needs RXB0CON.rxful = FALSE |
Posted: Mon Feb 23, 2009 4:26 pm |
|
|
Hi everyone,
I am having an odd issue with CAN. The CAN interrupts work and my code works much of the time. However, when I send a lot of messages to CAN, occasionally I find that the CAN receive interrupt no longer works. For instance, I have a bit of code that toggles the LED on a CAN interrupt. This does not execute once the CAN receive interrupt has "locked up", and the LED wont blink even when I send more CAN messages (slowly, once per second or so...)
Code: | #INT_CANRX0
#SEPARATE
void CANRX0isr(void)
{
output_bit(PIN_LED, !input(PIN_LED)); // Toggle LED state every second
ParseCAN();
CAN_INT_RXB0IF=FALSE;
RXB0CON.rxful = FALSE;
}
void ParseCAN()
{
int32 id32;
int data8[8];
int length;
int error;
int i;
can_getd(id32,data8,length,error);
cviRXCAN[nPacketReceived].CANid = id32;
cviRXCAN[nPacketReceived].CANlength = length;
for (i = 0; i < length; i++)
cviRXCAN[nPacketReceived].CANdata[i] = data8[i];
nPacketReceived++;
if (nPacketReceived == CAN_RX_BUFFER_SIZE)
nPacketReceived = 0;
fCANRX = TRUE;
} |
However, once I added the line above (RXB0CON.rxful = FALSE), the CAN never 'locked up' again. But looking at the "can_getd()" function from CCS, this should already be turning off RXB0CON.rxful = 0, so me doing it again shouldnt have an effect. (Note: the can_getd() is called in the 'ParseCAN' function called above)
Any ideas on what could be happening here to cause the can_getd() function to not reset the RXB0CON.rxful value? |
|