Other Parts Discussed in Thread: HALCOGEN
Tool/software: Code Composer Studio
Why do I not receive messages through CAN?
The code part for transmission and reception
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.
Tool/software: Code Composer Studio
Why do I not receive messages through CAN?
The code part for transmission and reception
Hello,
CAN is a multi-master serial bus standard for connecting to or more CAN nodes. All nodes are connected to each other through a two wire bus. The wires are a twisted pair with a 120 Ω (nominal) impedance.
More on CAN bus can be found here:
To connect two DCAN Modules of TMS570LC4357 LaunchPad you have to connect transceivers to drive CAN Bus. LaunchPad does not have transceivers on-board.
Hercules MCUs provides LoopBack mode on a CAN modules for testing purposes. When loop-back mode is enabled then you can test CAN modules without connecting them to CAN bus.
More on CAN module can be found in device TRM:
Loopback mode is used in "example_canCommunication_loopback.c" example that is in HALCoGen ..\examples\TMS570LC43x\ folder and setting MCU for this example is in HALCoGen-->Help-->Help topics-->Examples. "canEnableloopback(canREG1, Internal_Lbk);" function in the example enables Internal loopback for canREG1.
For sending and receiving messages you have to configure at least on Message box for Transmit and one Message box for Receive (See the Help for the example). In you code you are using the same boxes for Tx and Rx. In the example canREG1 is using Message box 1 for Tx and Message Box 2 for Rx.
canTransmit(canREG1, canMESSAGE_BOX1, (const uint8 *) &tx_data1[0]);
and
canGetData(canREG1, canMESSAGE_BOX2, (uint8 * )&rx_data1[0]); /* copy to RAM */
This example is using interrupt method. You can see examples in HALCoHen example folder for another MCU, where polling method is used.
Here is very useful explanation on message filtering:
I recommend you to start with the examples and than implement the code in your application.
Hello,
To connect two LaunchPads you have to connect transceivers to both sides (You can consider SN65HVDA541 transceiver and HDK schematics can be used as a reference. Schematic can be downloaded from here: ). Line has to be terminated with 120 Ohm resistors at both ends as well. In the first document I've posted above you can read more about CAN bus.