cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429 CAN bus example code to transmit and receive message using can bus analyzer

AChan.15
Associate II

Hi hello,

As iam new to stm32 i don't know how to use CAN bus to transmit and receive through CAN bus analyzer to stm32f4 controller, could some one help to give some sample or example code to send and receive message using CAN bus analyzer to stm32f429 using standard library. in web i could only find code for board to board and that to in hal library i need some example code in standard library

thanks in advance.

1 REPLY 1
AChan.15
Associate II

I have found one reference code and now it is working but I don't know how to calculate baud-rate for CAN for that, I have used some formula mentioned in CAN data sheet but still, it was not working. With the help of logic analyzer and find logic analyzer I could find the baud-rate of my board which the data is transmitting but if I apply that same data in that formula the value which I get is not the same from the logic analyzer

 /* CAN Baudrate = 625 KBps (CAN clocked at 25 MHz) */

 CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;

 CAN_InitStructure.CAN_BS1 =CAN_BS1_10tq ;

 CAN_InitStructure.CAN_BS2 = CAN_BS2_3tq;

 CAN_InitStructure.CAN_Prescaler = 5;

This is my configuration for CAN baud-rate for 625Kbps and it is working if apply these values in formula I am not getting the baud rate as 625Kbps.

from my assumption,

  tq=5

  tBS1=9

  tBS2=2;

NominalBitTime = 1 × tq + tBS1 + tBS2

BaudRate = 1/NominalBitTime 

can anyone tell me that I am using this value is correct or not because, I need to calculate it for different baud rate.it is very hard for me to calculate it by applying the random values to the BS1, BS2, and Prescalar.

thank in advance