Hi,
i have two circuits with PIC18F2685 communicating via CAN. Both PICs work with a 4MHz crystal. The PICs have internal CAN controllers. As a transceiver i use the TJA1050. In the CAN component properties i configured the internal use and a BAUD rate of 125KBaud. The circuit works fine, one circuit is sending CAN Messages and the other one is receiving.
I tried to see the CAN Messages with a PEAK Dongle on my screen but i couldn`t get any messages. Next, i looked at the width of a bit and so i figured out, that both circuits are working with a real BAUD Rate of 100kBaud.
So to summarize, configuring the circuit via the CAN component properties for 125kBaud gives a real BAUD rate of 100kBaud.
best regards
maridd
PIC18F2685 CAN with wrong BAUD Rate
Moderator: Benj
- 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: PIC18F2685 CAN with wrong BAUD Rate
Hello,
That's curious, I wonder if it's something to do with the 4MHz clock speed? Maybe 125KHz was not available from the divider ratio and hence 100KHz was the closest? Might be worth trying at 20MHz and see if this gives a better result?
That's curious, I wonder if it's something to do with the 4MHz clock speed? Maybe 125KHz was not available from the divider ratio and hence 100KHz was the closest? Might be worth trying at 20MHz and see if this gives a better result?
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
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: PIC18F2685 CAN with wrong BAUD Rate
As Ben said use a higher Clock Frequency ,4MHZ clock for a CAN application is not desired
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
Re: PIC18F2685 CAN with wrong BAUD Rate
Hi,
i can try a higher clock frequency. However, i have a running project with this PIC and a 4Mhz crystal and i used 50kHz. 50kHz is not available in the properties setting so i took the first available, which is 125kHz.
According to several timing calculators 125kHz should work with this clock frequency. But anyway, most probably i will switch to a higher clock frequency.
Thanks a lot
maridd
i can try a higher clock frequency. However, i have a running project with this PIC and a 4Mhz crystal and i used 50kHz. 50kHz is not available in the properties setting so i took the first available, which is 125kHz.
According to several timing calculators 125kHz should work with this clock frequency. But anyway, most probably i will switch to a higher clock frequency.
Thanks a lot
maridd
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: PIC18F2685 CAN with wrong BAUD Rate
With the 4MHz you can enable PLL which will give you 16MHz.
Just change clock frequency to 16000000
Just change clock frequency to 16000000
Martin
Re: PIC18F2685 CAN with wrong BAUD Rate
Hi,
i tried your idea to enable PLL and this sets the internal frequency to 16MHz. The strange thing is that despite the fact that i still have set 125kBaud in the CAN properties this gives me now a CAN frequency of 400kHz, so exactly 4 times the frequency i have without enabling PLL.
Because datatransfer via CAN works fine with clockfrequeny 4MHz and 100kBaud or even 16MHz internal (by PLL) and 400kBaud i will work with this result but i never get the transfer rates given in the properties.
maridd
i tried your idea to enable PLL and this sets the internal frequency to 16MHz. The strange thing is that despite the fact that i still have set 125kBaud in the CAN properties this gives me now a CAN frequency of 400kHz, so exactly 4 times the frequency i have without enabling PLL.
Because datatransfer via CAN works fine with clockfrequeny 4MHz and 100kBaud or even 16MHz internal (by PLL) and 400kBaud i will work with this result but i never get the transfer rates given in the properties.
maridd
Re: PIC18F2685 CAN with wrong BAUD Rate
Hi again,
to bring this post to an end... I calculated the CAN timing with a BIT calculator and wrote this values directly into the BRGCON register after the initialization icon for the CAN component, so my own values override the flowcode values. And this works with a clock frequency of 4MHz and a bitrate of 125kbps and of course with higher clock frequencies. Just wanted to let you know.
best regards
maridd
to bring this post to an end... I calculated the CAN timing with a BIT calculator and wrote this values directly into the BRGCON register after the initialization icon for the CAN component, so my own values override the flowcode values. And this works with a clock frequency of 4MHz and a bitrate of 125kbps and of course with higher clock frequencies. Just wanted to let you know.
best regards
maridd