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.

EKS-LM4F232 CAN Tx/Rx working separately but not together

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);

 

 

  • John,

     

    So you are receiving interrupts when you run TX and RX independently but not simultaneously?

     

    Is that correct?

     

     

     

     

  • I believe so, but the question is thought provoking.  The only way I get UART and LED indication that I Rx is active, is if the ISR is serviced for the Rx MsgObj.  The Tx UART and LED indication occur in the main loop and may not require ISR Tx section to happen.  I do not remember if I put a breakpoint in the ISR Tx section.  I will check.  It may take a day as I tore apart my bread board due to faulty sockets in it and am rebuilding my prototype with wire and solder.  (Kinda hoping the wire and solder fix the issue, but I think it is something like what you suggest, somehow my interrupt is not happening.)

    Give me a day or so.

    Thanks.

  • I will mark this as verified.  I reworked my protoboard and Tx/Rx are now working again... until I physically touch my board.  I assume I have some capacitance issue to chase down.  The interrupt stops occurring and the messages that are requested to be sent are not actually making it to the bus.  I have some scope work to do.

  • John,

     

    If you remember please post back when you resolve this issue so that others can benefit if they happen to run into the same issue.

  • After moving the CAN HW support off of a bread board and to a soldered proto board I have the same software as before working.  The last two issues were: cold solder joint on the RX bus side of the transceiver chip and moving a capacitor between +3V and ground from several inches from the transceiver chip to a quarter inch. 

    So the problem appears to be how I lashed the transceiver chip into the EKS-LM4F232.  It would have been nice to have the transceiver chip part of the EKS, such as on the EKS-LM3S8962 :)

    (I have not used a bread board in years, actually decades.  I now remember why: the sockets ohmed at mostly 0ohms accross a socket group, with intermitent opens and ~30kohm resistence.  Bread boards are ok for electronics 101 lab, but not when work gets serious.  The bread board is now in the trash.)

  • I am trying to download the sample code which you written.But not able to retrive please send the sample code to Satheesh.R@in.bosch.com

  • I am afraid that code is long gone.  The only remnant that remains is in the posting.  Sorry I could not help.