SPNA245 September 2020 TM4C1290NCPDT , TM4C1290NCPDT , TM4C1290NCZAD , TM4C1290NCZAD , TM4C1292NCPDT , TM4C1292NCPDT , TM4C1292NCZAD , TM4C1292NCZAD , TM4C1294KCPDT , TM4C1294KCPDT , TM4C1294NCPDT , TM4C1294NCPDT , TM4C1294NCZAD , TM4C1294NCZAD , TM4C1297NCZAD , TM4C1297NCZAD , TM4C1299KCZAD , TM4C1299KCZAD , TM4C1299NCZAD , TM4C1299NCZAD , TM4C129CNCPDT , TM4C129CNCPDT , TM4C129CNCZAD , TM4C129CNCZAD , TM4C129DNCPDT , TM4C129DNCPDT , TM4C129DNCZAD , TM4C129DNCZAD , TM4C129EKCPDT , TM4C129EKCPDT , TM4C129ENCPDT , TM4C129ENCPDT , TM4C129ENCZAD , TM4C129ENCZAD , TM4C129LNCZAD , TM4C129LNCZAD , TM4C129XKCZAD , TM4C129XKCZAD , TM4C129XNCZAD , TM4C129XNCZAD
This example interfaces a UART to a CAN bus. It receives data on UART2 then sends it out on CAN2 and receives data on CAN0 then sends it out on UART2. For this example UART2 is configured for 115200 baud (defined in UartFunctions.h) and CAN0 is configured for 1M baud (defined in CanFunctions.h). At these rates continuous data received on the UART will consume 17% of the CAN bus bandwidth.
Data received by either UART or CAN is handled by interrupt routines. The received data is put into its respective circular buffer. Both buffers are defined with a size of 256 bytes (defined in main.h). When continuous data is received on the UART, the UART interrupt routine is triggered after receiving four bytes, a half full FIFO. The data is then collected until eight bytes are received before being put in the circular buffer. This allows the CAN transmission to be the most efficient by supporting up to eight bytes in a CAN packet. When the UART reception halts or pauses, a receive timeout (RT) interrupt is generated. In this case, all the bytes in the UART receive FIFO are transferred to the circular buffer and a CAN frame of less than eight bytes is sent.
The arbitration ID for CAN transmitted messages and CAN received messages is the same, 0x101 (defined in CanFunctions.h). This allows two devices running the same software to transmit data from one serial port to another over a CAN network. With more than two devices on the network running the same software, data received on one serial port is transmitted through the CAN network and then output on the serial ports of all the other devices.
This example uses the following interrupt handlers. To use this example in your own application you must add these interrupt handlers to your vector table.