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.

TMS570LS0432: CAN - Using Interrupts to Transfer and Receive Data

Part Number: TMS570LS0432
Other Parts Discussed in Thread: HALCOGEN

Hi!

I am Chetan. I am basically trying to implement the CAN protocol on TMS570LS0432 controller. In this regard, I need to implement two CAN nodes, each capable of transmitting and receiving data on their respective CAN modules.

Basically, my concern lies in the algorithm of the software that I have to implement in order to configure the above nodes to have Tx and Rx functionality using interrupts. In this context, I have done the following things as per my understanding of Halcogen API's for CAN and the DCAN module on the controller. I just need some assurance as to whether this algorithm will work out correctly and if not, what is it that is wrong in my approach/understanding..

For one of the nodes, I have used "CanInit()" function to configure Message Box 1 to receive data by using IF1 (Interface Register 1) Arbitration, Mask, Command registers (In order to receive the correct identifier matching data in this message box). Now, I have the Receiver Interrupt Enabled for this message box through command register. (IE0 and IE1 both interrupt lines are enabled and all have been routed to IE0 as per MUX register setting and please note that "Error and Status Based Interrupts" have been disabled).

The "Can1HighLevelInterrupt" is definitely the ISR which the code will branch to whenever a message is received in message box 1 (Is this correct?). In this ISR, (the code branches to else part), the pending interrupt flag is cleared and a call is made to a function named, "canMessageNotification". Firstly, I want to know how is "Can1HighLevelInterrupt" as an  ISR different from "canMessageNotification"?

Secondly, inside the function "canMessageNotification", I am reading the identifier (using "canGetID" function) and based on certain bit sequence of the received identifier, I am calling the "canTransmit" function. Now, on having a look at "canTransmit" function, it no where sets the Tx Interrupt(enables it). So in other words, I have reception based on Interrupt but Transmission is initiated by just depending on data based on reception. Where and how do I enable transmission based on Interrupt? Also, if Transmission Interrupt is enabled, how do I modify the "CanHighLevelInterrupt" and "canMessageNotification" fucntions?

You can also share me some code snippet is possible so that I can have a better understanding. Thank you so much in advance.

Regards,

Chetan.

  • Hello Chetan,

    The notification is part of the ISR, but contains the customer's own code. During execution of the notification routine for a given interrupt request (for example, DCAN Msg box 1 RX interrupt), the interrupt remains disable at the CPU level (for IRQ). It is wise to have your notification routine as short as possible to avoid latency on any other pending interrupt.

    The receive interrupt is generated when the received data frame is accepted (through the filter) and stored in the message object (in Message RAM). In interrupt mode, the received data should be read out in canMessageNotification or CanHighLevelInterrupt. 

    The transmission interrupt (IntPnd) is generated after a message object is transmitted successfully. You can set a flag in CanHighLevelInterrupt or canMessageNotification to indicate that the transmission has been done successfully.