cancel
Showing results for 
Search instead for 
Did you mean: 

CAN communication on STM32MP157f-dk2

ienecode
Associate III

Hi,

I would like to use CAN communication on my devboard : STM32MP157f-DK2.

So I prepared OS, unfortunatelly I have to flash STM32MP157c-DK2 version according with problem described below:

Faulty boards out of the box 

So, after run OS, I edited *.dts file, by initialized &m_can1 device on PA11 and PA12 pins, which one exposed  on the board connector - CN2, and connected "MCP2542 click CAN bus transceiver" board.

In OpenSTlinux userspace I try recive CAN frames by command: candump can0, and there is any problem, because when I send full frame with 8 bytes that it doesn't arrive to device. Maksimum only 5 bytes in frame arrives, like below:

 

sendData.jpg

What can be wrong with CAN in STM ?
Please for any tips.

12 REPLIES 12

@SofLit  you're right. The STM32MP1 support FDCAN interface, and when I try turn off I get message:

 

root@stm32mp1:~# ip link set can0 type can bitrate 500000 dbitrate 1000000 fd off
RTNETLINK answers: Operation not supported

 

According with my knowledge frames with CAN2.0 can send to CAN FD. If I'm wrong please correct me.

What I discovered during the tests....

Originally I test my CAN communication with according with below set up socketCan interface:

 

ip link set can0 type can bitrate 500000 dbitrate 2000000 fd on

 

And Like I descirbed I had a problem, where only max 5 bytes data in frame arrive to STM32 from my test application.

Now I test  communication on 1M bitrate:

 

ip link set can0 type can bitrate 1000000 dbitrate 2000000 fd on

 

and the communication working, the CAN2.0 frames with 8 bytes payload data arrvied to STM32!

So, maybe now anybody can help me solve problem with 500kBaud transmission problem ? what could it be caused by?

I don't have idea how to configure the MPU environnement. But according to 

 

ip link set can0 type can bitrate 500000 dbitrate 2000000 fd on

 

Seems the FDCAN is activated: 500000b/s is the nominal bitrate and the 200000b/s is for the data phase bitrate. And your sender doesn't support that frame. SO you need to find how to set the FDCAN interface in CAN2.0.

So, you need to trun off the FDCAN mode: I think (I'm not sure): 

 

ip link set can0 type can bitrate 500000 dbitrate 2000000 fd off

 

-> for a nominal bitrate of 500kb/s where fd mode is off.

or try:

ip link set can0 type can bitrate 500000 fd off
or 
ip link set can0 type can bitrate 500000
To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
PS:
1 - This is NOT an online support (https://ols.st.com) but a collaborative space.
2 - Please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help.
SofLit
ST Employee

See this thread:

ip link set can0 type can bitrate 500000
ifconfig can0 up
To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
PS:
1 - This is NOT an online support (https://ols.st.com) but a collaborative space.
2 - Please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help.