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?
CAN BAUD RATE
Moderator: Benj
-
- Posts: 18
- Joined: Tue Aug 23, 2016 8:03 am
- Has thanked: 3 times
- Been thanked: 2 times
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: CAN BAUD RATE
Hello,
I believe for 50kbps you need the following Baud settings.
CAN_BAUD1 = 49
CAN_BAUD2 = 218
CAN_BAUD3 = 5
I believe for 50kbps you need the following Baud settings.
CAN_BAUD1 = 49
CAN_BAUD2 = 218
CAN_BAUD3 = 5
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 18
- Joined: Tue Aug 23, 2016 8:03 am
- Has thanked: 3 times
- Been thanked: 2 times
- Contact:
Re: CAN BAUD RATE
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.
// 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 );
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.
// 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 );