cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4xx CAN Bus error

shilpa Reddy
Associate II
Posted on November 30, 2017 at 10:57

Hello ,

I am working on STM32F4xx CAN interface with Busmaster . Here is my initialization code:

/* CAN cell init */

CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;

CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;

/* CAN Baudrate = 500KBps (CAN clocked at 24 MHz) */

CAN_InitStructure.CAN_BS1 = CAN_BS1_10tq;

CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;

CAN_InitStructure.CAN_Prescaler = 3;

I have taken the example code from peripheral library, the CAN seems to work fine in loop-back mode, however in the normal mode, I am not able to transmit messages. It updates the transmission mailbox, but when the transmission request is made,  ALST0 bit is set CAN_TSR register and  LEC[2:0]: Last error code is 100 in (CAN_ESR).

Could you help me figure out the issue, thanks..

#stm32f4xx-can-bus-error
2 REPLIES 2
shilpa Reddy
Associate II
Posted on November 30, 2017 at 14:50

Hi all,

I got it working by lowing the baud rate to 125kbps.  both at MCU and Busmaster.

/* CAN Baudrate = 125 MBps (CAN clocked at 24 MHz) */

CAN_InitStructure.CAN_BS1 = CAN_BS1_9tq;

CAN_InitStructure.CAN_BS2 = CAN_BS2_6tq;

CAN_InitStructure.CAN_Prescaler = 12;

CAN_Init(CANx, &CAN_InitStructure);
Posted on November 30, 2017 at 17:04

Consider if there is an issue with the transceiver or termination on the bus.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..