Page 1 of 1

CAN BAUD RATE

Posted: Wed Sep 26, 2018 8:47 am
by msahin1976
Hello,
I need to set can bus baud rate to 50kbps. I tried to do by writing C code, but nothing happened. Can anyone tell me how to do it?

Re: CAN BAUD RATE

Posted: Wed Sep 26, 2018 5:11 pm
by Benj
Hello,

I believe for 50kbps you need the following Baud settings.

CAN_BAUD1 = 49
CAN_BAUD2 = 218
CAN_BAUD3 = 5

Re: CAN BAUD RATE

Posted: Thu Sep 27, 2018 7:26 am
by msahin1976
Dear Benj,
Thank you for your answer.
I tried to change "BRGCON" register to set baud rate. The oscillator is 20 MHz. According to this clock, I set the register. The problem was writing to this register directly doesn't work. Later I found another subject CAN baud rate, and I changed the C code like below. Now baud rate is about 50Kbps. Sorry to disturb you. :oops:

// Request config mode.
cancon = MX_CAN_REQOP_CONFIG;
while( (canstat & MX_CAN_OP_MODE_BITS) != MX_CAN_REQOP_CONFIG );

// change the baud rate registers
brgcon1 =0b11001100;
brgcon2 =0b11101001;
brgcon3 =0b00000101;

// Request normal mode.
cancon = MX_CAN_REQOP_NORMAL;
while( (canstat & MX_CAN_OP_MODE_BITS) != MX_CAN_REQOP_NORMAL );