cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f0 discovery CAN bit timing

urban
Associate
Posted on November 19, 2014 at 17:29

Hello,

I'm having problems with bit timing configuration. I have 36MHz peripheral clock and need 500kBit/s on CAN. I'm having trouble, because I've calculated right value but I see on the oscilloscope that it isn't . Can someone please help me?

CAN_InitStructure.CAN_Prescaler = 3;

CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;

CAN_InitStructure.CAN_BS1 = CAN_BS1_12tq;

CAN_InitStructure.CAN_BS2 = CAN_BS2_3tq;

thanks in advance
3 REPLIES 3
Posted on November 19, 2014 at 18:04

By my estimation you have a 750kbaud setting

APB / ((SWJ + BS1 + BS2) * Prescaler)

ie APB / 48

You'd need APB / 72 for a 500kbaud rate from a 36 MHz bus clock.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on November 19, 2014 at 18:07

/* CAN Baudrate = 500KBps for 36 MHz */

  CAN_InitStructure.CAN_SJW = CAN_SJW_1tq; // 1..4

  CAN_InitStructure.CAN_BS1 = CAN_BS1_3tq; // 1..16

  CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq; // 1..8

  CAN_InitStructure.CAN_Prescaler = 8; // 1..1024

  CAN_Init(CANx, &CAN_InitStructure);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
urban
Associate
Posted on November 21, 2014 at 13:02

Thank you very much. it's working now.