Bug in CAN baudrate in dspic V5.5.2.1

Moderator: Benj

Post Reply
r_romeo
Posts: 54
Joined: Wed Nov 02, 2011 3:57 pm
Has thanked: 14 times
Been thanked: 3 times
Contact:

Bug in CAN baudrate in dspic V5.5.2.1

Post by r_romeo »

Hi ,

I just found the Baud rate generated setting external CAN is wrong because the CRANCKS bit (11) of C1CTRL register is = 0 instead of 1

to solve this I just add C code :

C1CTRL = (C1CTRL || 1024) ;


I am using dsPIC version on dsPIC30F4012 not sure if applies yo other devices

Cheers

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: Bug in CAN baudrate in dspic V5.5.2.1

Post by Mikat »

Hi.
This is the bug what I was talking some thread earlier..
The thing is that Flowcode set the CANCKS bit at 0, and then the whole CAN engine runs at FOSC/4, but the flowcode uses the FOSC at the baudrate calculation, so the values which flowcode shows is 4 times too high..
So the error can be solved to put baudrate 4x as it should be eg. if you have 250kbs CAN speed, you must set the CAN speed at 1000kbs..
The CANCKS bit MUST be at 0, if the FOSC is over 30MHz (actually at me the limit was somewhere like 50MHz, and the the CAN didn't work as it should, at 100MHz it didn't work at all..).
By the way, the CANCKS is bit 11, so shouldn't the fix be C1CTRL = (C1CTRL || 2048) ;?
Or C1CTRLbits.CANCKS=1;

T:Mika

r_romeo
Posts: 54
Joined: Wed Nov 02, 2011 3:57 pm
Has thanked: 14 times
Been thanked: 3 times
Contact:

Re: Bug in CAN baudrate in dspic V5.5.2.1

Post by r_romeo »

Hi Mika
you are right, I made a mistake with C1CTRL = (C1CTRL || 1024), the weird thing is that with that setting my Baudrate is fixed!!, I tried erasing that block just to check and the block with bit 10 = 1, solves the baudrate problem (????!!!!)

Post Reply