Page 1 of 1

Bug in CAN baudrate in dspic V5.5.2.1

Posted: Fri Apr 05, 2013 2:14 pm
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

Re: Bug in CAN baudrate in dspic V5.5.2.1

Posted: Tue Apr 16, 2013 6:27 am
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

Re: Bug in CAN baudrate in dspic V5.5.2.1

Posted: Tue Apr 23, 2013 11:21 am
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 (????!!!!)