CAN BAUD RATE

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
msahin1976
Posts: 18
Joined: Tue Aug 23, 2016 8:03 am
Has thanked: 3 times
Been thanked: 2 times
Contact:

CAN BAUD RATE

Post 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?

User avatar
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

Post by Benj »

Hello,

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

CAN_BAUD1 = 49
CAN_BAUD2 = 218
CAN_BAUD3 = 5

msahin1976
Posts: 18
Joined: Tue Aug 23, 2016 8:03 am
Has thanked: 3 times
Been thanked: 2 times
Contact:

Re: CAN BAUD RATE

Post 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 );

Post Reply