Hi Pierre,
The example code in the AN4241 is almost correct. You need to do a EVB connection as it is showed in the AN4241 in Figure 6. That is connect CAN TX lines together, CAN RX lines together and connect this pair to the trasnsceiver.
The TX lines are set in open drain configuration. This is needed in such connection , but also you need an external pull-up resistor on TX line or at least set internal weak pull-ups for TX line.
Do you have it? If not then use it.
However there is also another issue with this example. There are several requirements for CPI (CAN Protocol Interface) and system clocks for correct FlexCAN module’s arbitration and matching timing. This is stated within device Reference Manual in chapter 28.4.7.5 Arbitration and Matching Timing.
In details..
- A valid CAN bit timing must be programmed
- The system clock frequency cannot be smaller than the oscillator clock frequency, i.e.,the PLL cannot be programmed to divide down the oscillator clock.
- There must be a minimum ratio of 16 between the system clock frequency and the CAN bit rate.
So the second one is not fulfilled as there is no system clock setting, so it is running from the 16MHz IRC by default.
Add a PLL setting and select it as the system clock. Then the example should work.
Attached is the modification of the main.c I did.
Hope it helps.
Regards,
Petr