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.

TCAN1051H: How to send multiple frames in CAN

Part Number: TCAN1051H
Other Parts Discussed in Thread: TCAN1051, TCAN4550


I am working on a CAN  Bus project with TCAN1051 and STM32. In this project i have to send approx. 175 bytes of data though CAN. It will take around 22 frames to send this data. And i can't figure out how to send all the frames. If i send all of them at once i might get RX_FIFO overflow error. Can anyone help me with this. Thanks

  • Hi Ashish,

    I assume that your STM32 device has a CAN controller built in. Can you confirm this?

    The first thing I will suggest is upgrading to an FD capable device. The reason for this is that with an FD capable device you can send up to 64 bytes of data in each CAN frame. CAN FD can also transmit at higher rates so even if you are still sending your data in 22 frames the data portion of those 22 frame will come out much faster.

    Now to explain how this work let's first start out with the transceiver itself, the TCAN1051. Any standalone transceiver like the TCAN1051 is a "dumb" device. All it will do is take what is on TXD and put it on the CAN bus. Then it takes whatever is on the CAN bus and puts it on the RXD pin. This is all the device does. it is not intelligent enough to know what a CAN frame is and what the different parts of the CAN frame are.

    This is where your CAN controller will come in. Your CAN controller is what sets up your CAN frame and then sends it out to your CAN transceiver on the TXD pin. Then if it sees a CAN frame coming back on the RXD pin it will decode that frame and turn it into data that your MCU can understand. A very popular CAN controller is Bosch's MCAN IP. If your microcontroller doesn't have a CAN controller built in you can try and write your own with the microcontroller or you can look at our TCAN455x family of devices. The TCAN455x family integrates a CAN controller and a CAN transceiver into the same package. So you hook up the TCAN455x using SPI to your MCU. Then you set up the device using SPI and the integrated controller will send out the CAN frames and will automatically read back any CAN message. We even have example code written for the TCAN4550 so you can get started fairly easily.

    If you do have a built in CAN controller than the way that you send a message is typically you have to set your clock speed and prop segments first. This determines how fast of a message you will send. Then you set up your CAN header. The header has your ID, DLC bit, RTR, etc. If you are using a CAN FD device and you would like to enable a CAN FD message then you need to configure your bit rate switch and your CAN FD format flag. Once your header is set up you will need to set up your data. I assume that most CAN controllers will have a transmit buffer. All you have to do is write your header and data to the transmit buffer and from there you tell your CAN controller which buffer you would like to send a frame from. Then the CAN controller packages up the message and sends it. 

    The RX_FIFO overflow error is based on receiving the messages not sending it. Usually your MCU can process and store a CAN message extremely fast especially if it is classic CAN where the messages are slow and you can only send 8 bytes of data. However, you are correct with an RX_FIFO you do have a potential of overflowing and losing some data. I'm sure that most CAN controllers will allow you to set the size of your RX_FIFO based on how much ram they give you. So you could increase the FIFO size or, what is probably a better solution, you should work on optimizing your MCU to read in data much faster and store it itself in a different buffer/FIFO. All you have to do is get the data off of the RX_FIFO in the CAN controller. Once it is off of the FIFO you can process the data later if you would like in the much larger buffer that your MCU has access to.

    If you decide to go with the TCAN455x let me know we have a lot of really good documentation for this family of devices.



  • Hi Chris,

    Thanks for this detailed answer. I am using STM32G0 series microcontroller and it has built in CAN-FD. First I tried with CAN-FD frame format and I was able to send all the data in 3 frames only. But for another project i have to use CAN- Classic format. I tried sending all the 26 frames one by one with 10 ms delay. I will also try your suggestions. Thanks

  • Sounds good Ashish,

    Let me know how it goes.