Firmware
17
SLLU216 – July 2019
Copyright © 2019, Texas Instruments Incorporated
SPI to CAN FD SBC + LIN Transceiver BoosterPack User's Guide
4. Write the CAN message to the MRAM memory.
5. Send the transmission request to the TCAN4550-Q1.
Once the above process is completed, the TCAN4550-Q1 starts the transmission process and an entry is
added to the event FIFO that can be read by the microcontroller.
The example firmware sends a CAN message every time the S1 switch is pressed on the MSP-
EXP430FR6989 LaunchPad. The contents of this message are always the same and can be modified by
changing the code to customize it for your application. Pressing a push-button switch was an easy event
to use for an example of how to send a CAN message. Simply replace this code with your own code that
causes the TCAN4550-Q1 to send a CAN message as desired in order to customize it for your
application.
3.2.2
Receiving a message
The process to read a received message may differ slightly based upon how the TCAN4550-Q1 was
configured. A more detailed example of this process can be found in section 4.3.2 of the
. A basic process is as follows:
1. Determine where the new message is (RX FIFO 0, RX FIFO 1, or RX Buffer).
2. Based upon the buffer location of the new message, determine the buffer index and then the start
address to read from MRAM.
3. Read the MRAM to retrieve the message.
4. Acknowledge the new message is read to release the FIFO element and make it available for a new
message.
The process varies slightly depending on if the new message is in a RX Buffer or a RX FIFO; since they
are fundamentally different. The FIFOs require the microcontroller to read a FIFO status register which
tells the microcontroller how many new messages are in the FIFO, and what index to start reading at. The
buffer requires the microcontroller to read the New Message Register, which tells the microcontroller
which buffers have unread messages in them. At the end of each read, the microcontroller must let the
TCAN4550-Q1 know that the message has been received in order to release the element for reuse.
In the example firmware, the message contents can be seen through the use of the debugger by setting a
breakpoint on the line of code following the line where the message is read from the TCAN4550-Q1. The
following line of code is the line that reads message from the TCAN4550-Q1.
numBytes = TCAN4x5x_MCAN_ReadNextFIFO( RXFIFO0, &MsgHeader, dataPayload); // This reads
the next element in the RX FIFO 0
Place the breakpoint on the next line of code:
if (MsgHeader.ID == 0x0AA) // Example of how you can do an action based off a received address
From the Debugger's Variables window, you can view the message contents by expanding the
MsgHeader variable by clicking on the arrow. Once you are comfortable with receiving this message data,
you can simply add your own code to this if statement and customize it for your application.
3.3
Performance Optimization
There are several issues that can have a negative impact on the CAN throughput performance. The
microcontroller firmware should be designed to minimize these effects in order to maximize performance.
The most common issue that hurts CAN throughput is poor SPI throughput. Excessive idle time between
the chip select going low and the start of the data, or the time between the end of the data and the chip
select going high, and the idle time between the MCU's SPI words can all contribute to a lot of idle time
and increase the amount of time required between CAN messages being transmitted on the bus.
Structuring the code to minimize these idle times ensures that maximum possible CAN throughput is
possible.