I have an example bit of code working. When the EKS is not sending messages, it easily catches all messages on the CAN bus. When I disable that functionality, the code then starts transmitting a message every second or so. When both features are enabled, after the first message is transmitted by the EKS, the EKS stops receiving messages. To be exact, the interrupt is not tripped by an Rx, even though the CAN registers sure look like there is a CAN Rx interrupt pending and all the intended interrupt enables are still enabled.
I use MsgObj 1 for Tx and 2 for Rx on CAN0.
Why would a Tx on MsgObj 1 disable Rx on MsgObj 2?
My interrupt routine looks like:
//*****************************************************************************
//
// The CAN controller interrupt handler.
//
//*****************************************************************************
void
CANIntHandler
(void)
{
unsigned long ulStatus;
ulStatus =
CANIntStatus(CAN0_BASE, CAN_INT_STS_CAUSE);
if(ulStatus == 1)
{
g_ulMsgCount++;
g_bErrFlag = 0;
}
else if(ulStatus == 2)
{
CANMessageGet(CAN0_BASE, 2, &sCANMessageRx, 1);
g_ulMsgCount++;
g_bRXFlag = 1;
g_bErrFlag = 0;
}
else
{
CANStatusGet(CAN0_BASE, CAN_STS_CONTROL);
}
CANIntClear(CAN0_BASE, ulStatus);
}
Out in the main loop, the TX code is (between an LED blinking and a UART message, I know Tx has occurred):
GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_0,
(
GPIOPinRead(GPIO_PORTK_BASE, GPIO_PIN_0) ^
GPIO_PIN_0));
CANMessageSet(CAN0_BASE, 1, &sCANMessageTx, MSG_OBJ_TYPE_TX);
UARTprintf("Tx 0x%08X len=%u data=0x",
sCANMessageTx.
ulMsgID, sCANMessageTx.ulMsgLen);
for(uIdx = 0; uIdx < sCANMessageTx.ulMsgLen; uIdx++)
{
UARTprintf("%02X ", ucMsgDataTx[uIdx]);
}
UARTprintf("\n");
And when the g_bRxFlag is set (and by the lack of LED and UART activity, I know this code is not exercised after the first Tx)
if(sCANMessageRx.ulFlags & MSG_OBJ_DATA_LOST)
{
UARTprintf("CAN message loss detected\n");
// Need to reset this flag manually as Stellaris API does not include this functionality
// Clear the MSG_OBJ_DATA_LOST.
sCANMessageRx.
ulFlags &= ~MSG_OBJ_DATA_LOST;
// Set the new state of the message object.
CANMessageSet(CAN0_BASE, 2, &sCANMessageRx, MSG_OBJ_TYPE_RX); }
//
// Print out the contents of the message that was received.
//
UARTprintf("Rx 0x%08X len=%u data=0x",
sCANMessageRx.
ulMsgID, sCANMessageRx.ulMsgLen);
for(uIdx = 0; uIdx < sCANMessageRx.ulMsgLen; uIdx++)
{
UARTprintf("%02X ", ucMsgDataRx[uIdx]);
}
UARTprintf("total count=%u\n", g_ulMsgCount);