CAN bus HW testing (STM32MP157CAA)

25 views Asked by At

Hi I am trying to write a c/c++ application which will excercise the Tx and Rx pins of the can interfaces (can0 and can1) available in the STM32MP157CAA.

Approach One I wrote an application which opens a socket on can0 and then writes into the Tx of can0 receive the same bytes on the Rx of can0. And same for the can1. I followed the loopback mechanism described in the below ST wiki: https://wiki.st.com/stm32mpu/wiki/How_to_send_or_receive_CAN_data#Hardware_self-test

This works. But it turns out that the above loopback happens internally and doesn't actually send the packet through the Tx pin.

Approach Two Now, I am thinking if I can physically connect the Tx of can0 with the Rx of can1 using a female to female connector, and then open two separate sockets for can0 and can1, write on the Tx of can0 and then try receiving on the Rx of can1 - should that work? I have given it a quick try but doesn't seem to be working.

I am not sure technically if this approach is even valid. Can anyone please help to understand if this is at all possible? I wanted to double check before going into further investigation.

Approach Three If this doesn't work, then only other option would be to get another board and then physically connect the Tx of can0 of board A to the Rx of can0 of board B. But is that absolutely necessary? Shouldn't we be able to send from one can interface (can0) and receive on the other (can1) on the same board?

Note: My reference to can0 and can1 is from using SocketCAN. On the board schematics the two can interfaces are called can1 and can2 respectively. Just wanted to clarify.

I have attached the screenshot of the can1 and can2 pins below:

enter image description here

Edit: Do I need to use a CAN transceiver in Approach Three between the two CAN nodes to be able to talk to each other?

So far I have tested all of the above three approaches and none are working.

0

There are 0 answers