Hi,
Using a PIC18F2585 with an 8mHz Crystal. Using the internal CAN at 1000Kbit. The CAN is not output at the correct Bit rate.
I would like to run the PIC using the HS PLL option, thus running the internal clock at 32MHz.
If I put a 20MhZ crystall on the board the PIC outputs the CAN at the correct speed.
I understand the BRGCON1 Register (Baud Rate Control) prescaler must be set for each internal clock frequency, to ensure the internal CAN's clock is correct.
CANCON also needs to be set to enter Configuration mode.
This is all starting to get on the edge of my capability, does anyone have more knowledge on the correct BRP setting to enter for a given frequency.
and how do you enter and exist the configuration mode.
Thanks. J.
PIC, changing CAN bit speed Settings. BRP BRGCON1
-
- Posts: 220
- http://meble-kuchenne.info.pl
- Joined: Sun Dec 20, 2020 6:06 pm
- Has thanked: 82 times
- Been thanked: 58 times
-
- Valued Contributor
- Posts: 1037
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 198 times
- Been thanked: 218 times
Re: PIC, changing CAN bit speed Settings. BRP BRGCON1
Hi jay_dee
I don't know anything about CAN.
You can find more information in the PDF
For my PIC32 I used C-code like this
I don't know anything about CAN.
You can find more information in the PDF
For my PIC32 I used C-code like this
- Attachments
-
- CAN_00738b.pdf
- (114.53 KiB) Downloaded 282 times
Re: PIC, changing CAN bit speed Settings. BRP BRGCON1
Thanks Stefan,
I change the register values the same way. Using the C code.
My issue is that it can get pretty tricky to calculate what the values need to be for the registers. Then there is an issue that you have to enable configuration mode, make changes and exit, with what looks like some specific checks/timing. Its just a bit beyound where my skill level is at!
There is a document from Microchip on timing but it just fried my noodle!
https://ww1.microchip.com/downloads/aem ... /00754.pdf
I'm also using the HS PLL setting (XTAL x4), so assumed the frequency to scale is the 32MHz and not the base crystal frequecny of 8MHz.
I assumed I needed to take the OSc Frq of 32Mhz and divide this down to the required CAN module frequency, which at a guess is 20MHz?
But looking at the documentation, its all way more complex than that!
I change the register values the same way. Using the C code.
My issue is that it can get pretty tricky to calculate what the values need to be for the registers. Then there is an issue that you have to enable configuration mode, make changes and exit, with what looks like some specific checks/timing. Its just a bit beyound where my skill level is at!
There is a document from Microchip on timing but it just fried my noodle!
https://ww1.microchip.com/downloads/aem ... /00754.pdf
I'm also using the HS PLL setting (XTAL x4), so assumed the frequency to scale is the 32MHz and not the base crystal frequecny of 8MHz.
I assumed I needed to take the OSc Frq of 32Mhz and divide this down to the required CAN module frequency, which at a guess is 20MHz?
But looking at the documentation, its all way more complex than that!
Re: PIC, changing CAN bit speed Settings. BRP BRGCON1
Hi jay_dee,
I have not done anything with CAN using Flowcode but I used a CAN bit timing calculator such as https://kvaser.com/support/calculators/ ... alculator/
For a PIC device I used MCP2510 and then worked it back from there. I have never used PLL but I would assume you put the 32mhz in as the clock frequency.
If you need any more help I will have to look up what I did years ago.
Are you looking at your own network or an existing one as when I was looking 1Mbit was considered too high for anything but very well designed systems.
Bob
I have not done anything with CAN using Flowcode but I used a CAN bit timing calculator such as https://kvaser.com/support/calculators/ ... alculator/
For a PIC device I used MCP2510 and then worked it back from there. I have never used PLL but I would assume you put the 32mhz in as the clock frequency.
If you need any more help I will have to look up what I did years ago.
Are you looking at your own network or an existing one as when I was looking 1Mbit was considered too high for anything but very well designed systems.
Bob
Re: PIC, changing CAN bit speed Settings. BRP BRGCON1
The other thing which is confusing me is that you say you are using the internal CAN (and you are using a CAN enabled device) but in FC the only CAN component I can find is "CAN (Internal MCP2515)" which is an external SPI / CAN device?
Bob
Bob
Re: PIC, changing CAN bit speed Settings. BRP BRGCON1
I had to give up on this, I could not get anything that seems to work. I read lots and used various tools but its beyond my skills.
I'll just have to stick to a plain old 20Mhz crystall and with that internal CAN works fine.
A shame but burnt too long and got no where.
I'll just have to stick to a plain old 20Mhz crystall and with that internal CAN works fine.
A shame but burnt too long and got no where.
-
- Matrix Staff
- Posts: 1517
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 212 times
- Been thanked: 351 times
Re: PIC, changing CAN bit speed Settings. BRP BRGCON1
Sorry this is late, but there are some potentially useful posts on the Microchip forums (although some of the posters seem pretty rude on there). For example this one:
https://forum.microchip.com/s/topic/a5C ... 560?page=1
Also, some more here:
https://www.google.com/search?q=PIC18F2 ... rochip.com
https://forum.microchip.com/s/topic/a5C ... 560?page=1
Also, some more here:
https://www.google.com/search?q=PIC18F2 ... rochip.com