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.

TMS570LS1224: Sending multiple messages over CAN

Part Number: TMS570LS1224
Other Parts Discussed in Thread: TMS570LC4357, HALCOGEN,

I'm testing out the CAN interface between the TMS570LS12x MCU on a TMS570LS1224 Hercules Development board with the Cortex R4F MCU and the TMS570LC4357 without any interface devices (I'm just using a breadboard and some CAN transceivers). I'm using the CAN driver files generated from HALCoGen (can.c and HL_can.c), and I'm trying to figure out the best way to send and receive multiple messages (with the goal of being able to send over larger messages and files using CAN).

Currently, I've had a bit of success by calling a sleep() function in between my canTransmit() calls on the transmitting end and checking canIsRxMessageArrived() and calling canGetData() multiple times on the receiving end, but my intuition tells me this is not the ideal way of doing it. 

I've seen in some other forum posts that it's possible to set up some sort of buffer to receive the messages but I haven't been able to figure out how to code this. 

I'm wondering if using a sleep() function when transmitting calls and continuously calling canIsRxMessageArrived() / canGetData() is the appropriate way to do things or if you can suggest a better method? If so (ex: by using some sort of buffer), is there any example code somewhere that demonstrates what something like this might look like?

Thanks

  • Hello,

    You can consider using interrupts. Take a look at example that shows how to use interrupt method. You can see how to use the example in HALCoGen-->Help-->Help topics-->Examples. The example name is: example_canIntCommunication.c

  • Thanks, this looks like it would get the job done.
    One additional question, if I'm using 2 boards instead of 1 like the example uses, how would I coordinate when to send each next chunk of the message? 
    Would I ideally want to send some sort of CAN message from the receiving board when it receives a chunk from the transmitting board so that the transmitting board knows it can safely send the next chunk?

     

  • Hello,

    You could implement some kind of handshaking. You can consider using a remote frame as well (See chapter 27 in TRM for more on remote frames).