This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

interpreting CAN_STATUS_RXOK

Hi

 

I’m working with CAN on a TM4C123, using the example in the Tiva peripheral library.

I've successfully uploaded the example simple_rx.c to my board. Using a 'scope I can see messages arriving at the board (though I don’t know for certain yet they’re correctly configured), whereupon the interrupt handler CANIntHandler() gets called.

In the example code, CANIntHandler() determines the cause of interrupts via

ui32Status = CANIntStatus(CAN0_BASE, CAN_INT_STS_CAUSE);

In my case, the returned value is

ui32Status == CAN_INT_INTID_STATUS

 

Simple_rx.c implies this indicates some sort of error occurred (since otherwise the code says “else if ui32Status ==1”)

 

The example goes on to say that you can diagnose the error by calling

 

ui32Status = CANStatusGet(CAN0_BASE, CAN_STS_CONTROL);

 

and examining the field of error bits returned

 

When I do this however, the return value I'm seeing is

 

ui32Status = CAN_STATUS_RXOK    (i.e. "a message was received successfully”)

 

 

(I’m determining this simply by adding some lines to compare ui32Status against all allowed values -

           If (ui32Status & CAN_STATUS_BUS_OFF)  UARTPrintf(“BUS OFF”);

           If (ui32Status & CAN_STATUS _EWARN)   UARTPrintf (“EWARN”);    

//Etc.  )

 

I’m struggling to interpret this: On the one hand the call to CANIntStatus() didn’t return ‘1’, implying a problem…but the 'problem' is “RXOK - a message was received successfully”.

What am I missing?

And/or, if there is a problem with my CAN messages, is there a way to get some further diagnostic information from the API?

Many thanks for any help

  • Hello Harry,

    The specific definition of the status code is "Since this bit was last cleared, a message has been successfully received, independent of the result of the acceptance filtering." This is separate from a normal RX where the acceptance filtering is applied. Note that this may or may not be considered as an error by the system/application dependent on how CAN is used.