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
Bug in CAN baudrate in dspic V5.5.2.1
Moderator: Benj
-
- Posts: 258
- Joined: Wed Nov 29, 2006 6:32 pm
- Location: Finland
- Has thanked: 7 times
- Been thanked: 36 times
Re: Bug in CAN baudrate in dspic V5.5.2.1
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
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
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 (????!!!!)
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 (????!!!!)