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.

TM4C1294XL CAN0 not triggering interrupt when sending message

Other Parts Discussed in Thread: TM4C129XNCZAD

Hello,

I'm trying to get the CAN0 working on the TM4C1294XL connected launchpad. I modified the simple_tx.c file and I'm pretty sure the configuration is done correctly. The problem is that the following code doesn't trigger the ISR. 

 CANMessageSet(CAN0_BASE, 1, &sCANMessage, MSG_OBJ_TYPE_TX);

With the setting sCANMessage.ui32Flags = MSG_OBJ_TX_INT_ENABLE; an interrupt should be triggered whenever a message is sent, am I right?

 

Thanks.

  • Hello Yunfei,

    That is correct that on successful transmission an interrupt must get generated. However the code section mentioned here is not sufficient for us to help

    1. Is the Interrupt Handler for CAN Mapped in the startup file?

    2. Is the Interrupt Enable for the CAN Module set in the test code you have?

    The full project view would be rather useful

    Regards

    Amit

  • Hi Amit,

    Thanks for the reply. By saying successful transmission, do I need to hook up a receiver and actually have another microcontroller to receive the transmitted message? My TM4C1294XL currently doesn't connect to anything (no transceiver to convert CAN0Rx and CAN0Tx to CAN-H and CAN-L), I just set up a break point in the ISR and it never breaks. 

    About your questions, please find attached test project file. Hope to hear back from you soon. Thanks!0552.can_test2.zip

  • Hello Yunfei,

    No wonder there is no TXOK Interrupt. You need either to enable the loopback mode so that it can read what it sent so that you can develop comnfortability or hook it up to a transciever.

    I think first we should get the bus topology corrected before debugging further.

    Regards

    Amit

  • Hi Amit,

    Thanks again for your prompt response.

    How should I enable the loopback mode? I didn't find a function to do so in the API.

    I'm new to CAN communication and I appreciate if you could answer some of mine basic questions:

    1. is the loopback mode same as connecting can0tx and can0rx together?

    2. if I hook the lauchpad to a transciever, do I need another set to actually receive the message?

    3. why is the loopback mode or a transciever is needed to send the message? Some kind of acknowledgement is required?

    Sorry for the dumm questions. The materials I found online confuses me more.

    Thanks,

    Yunfei

  • Hello Yunfei,

    To set the loopback mode you would need to set CANCTL.TEST bit and CANTST.LBACK bit. CAN protocol is based on ACK of there being at least one listner on the bus. The other aspect is that it is a shared bus, so there can be more than one transmitters, so it is necessary that a Transmitter makes sure that it's transmission did not get corrupted.

    AFAIK, it is not required to set the receive buffer.

    Regards

    Amit

  • Hi Amit,

    I have setup the communication correctly. I'm trying to receive message but the CANStatusGet returns 0x62. In the CANSTS register, the EWARN EPASS  are set to 1, and LEC bits are set to be 2. How should I proceed to find out why that happened?

    Using oscilloscope, I'm able to see the CAN0Rx does have signals coming in, but the interrupt is not triggered by TXOK.

    Thanks,

    Yunfei

  • Hello Yunfei,

    Have you set the internal loopback mode?

    Regards

    Amit

  • Not yet, I hookup the lauchpad can0rx and can0tx to a transceiver which is terminated with a 120ohm resister then connect to a device which send CAN signals when bootup.

    I saw the signal on oscilloscope, and the ISR was triggered 96 times and then stopped. The status register is described in the above post.

    Thanks,

    Yunfei

  • Hello Yunfei,

    It seems that the RX had to be set (I may have been wrong). The EWARN status bit getting set indicates that 96 TX errors got accumulated.

    I may have an example, but would need to check for TM4C129 (original was for TM4C123), that I should be able to send it across in a couple of days.

    Regards

    Amit

  • Hello Yunfei,

    I have attached a TM4C129 CAN Example. It uses internal loopback and works fine. You can monitor the CAN TX Line.

    Please note that it requires a TM4C129XNCZAD device as UART and CAN lines are not shared. On the connected LaunchPad the UART will not work as it is shared with CAN pins. So you would need to comment out the UART Configuration and Print Statements.

    http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/908/5140.TM4C129_5F00_CAN.7z

    Regards

    Amit