2014-11-19 08:29 AM
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 advance2014-11-19 09:04 AM
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.2014-11-19 09:07 AM
/* 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);2014-11-21 04:02 AM
Thank you very much. it's working now.