Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

CAN Communication Speed

Status
Not open for further replies.

urakhai911

Newbie level 6
Joined
Apr 15, 2010
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,413
Hey EDA World,

I am working on integrating CAN and USB together on the same PIC on the Ethernet Starter Kit.

The example code that came with the CAN library had the PIC configured it work at 80 MHz but successful communication only occurred at 4Mhz.


Code C - [expand]
1
CANSetSpeed(CAN1,&canBitConfig,80000000,1000000);



80000000 = System Speed
1000000 = 1Mbit Communication

I am using an external oscillator which is configured to 80Mhz with PLL for the system frequency. The problem is that even though the in the initialization I tell the CAN module that the PIC is operating at 80Mhz it doesn't work. When I tell it that it is working at 80Mhz and switch the clock to the internal clock configured to 4Mhz then it works.

I am extremely confused, is this a problem with the library or is it something that I am doing.

P.S. I know the problem isnt with the external oscillator because i configured the internal FRC oscillator to 80Mhz to check and I get the same results.

Any suggestions would be appreciated! Thanks a lot!
 

Have you already implemented USB on the device as well?

If so, I believe the problem maybe related to the clocking configuration requirements of the USB interface and stack:

The USB OTG module requires a 48 MHz clock. There are three methods for providing this clock:

• Use the 8 MHz FRC internal oscillator
• Provide a 48 MHz oscillator on the OSC1/OSC2 pins
• Use the 96 MHz USB PLL from OSC1/OSC2

The USB PLL is enabled via the UPLLEN Configuration bit. The oscillator source on the OSC1/OSC2 pins must operate at a frequency that is a multiple of 4 MHz. This frequency is divided down to 4 MHz by the USB PLL prescaler. The USB PLL prescaler does not automatically sense the incoming oscillator frequency. The user must manually set the PLL divider appropriately to generate the required 4 MHz output, using the UPLLIDIV Configuration bits. The 96 MHz PLL output is then fed into a fixed divide-by-2 frequency divider to generate the 48 MHz USB clock. The system and peripheral bus clocks are not affected by the use of the USB PLL. Alternately, the FRC can be used when the USB module needs a clock source upon exit from Suspend mode. The FRC source is selected by setting the OSCCON<UFRCEN> bit.


**broken link removed**

I ran into similar problems using the PIC 18F series:

USB and CPU clock selection on PIC 18F

I have not yet implemented both USB and CAN on a PIC32, so I cannot speak from experience. However, the 4MHz which is a multiple of 48MHz/96MHz required for USB definitely rings a bell. I seem to remember that value coming up time and time again when I was have issues with the PIC 18F series.

You may want to try setting the USB PLL to 96MHz along with adjusting all relevant code settings.

I do some more digging and see what surfaces.

Ciao
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top