CANbus timings on Microchip 18F processors

| No Comments | No TrackBacks
We've been using Microchip's 18F2580 and 18F4580 processors for most of our CAN projects.  They are readily available and have the CAN protocol module already on board.  Connect the processor to an Automotive CAN transceiver like the NXP PCA82C251 and you have a quick solution.    I was forced into using CAN when we built a replacement PCM for REVOLT's Mazda 3 project and have become a convert.  CAN is pretty easy to use, and seems to work quite well even in very noisy environments. 

The biggest challenge of using CAN is getting all of the timings right for the bus speed you are using.  There are a couple registers that have to be set just right.  In Microchip this is the BRP (Baud Rate Prescaler), SYNC, PHSEG1 and PHSEG2, and PROPSEG.  The latter values are summed to find out how many (scaled) clock cycles makes one bit.  For some reason Microchip likes giving all of its equations backwards.  The equations explain how to calculate the bus speed based on the register values.  Most designers want the other way, they know the bus speed they want, and need to solve for the register values.  Its a pain.

The good news is other people have suffered the same pain, and some of them wrote tools to help with the calculations.  The best I've found for CAN so far is from Intrepid Control Systems.  Their Microchip Controller Area Network (CAN) Bit Timing Calculator makes it easy. Give it the clock speed and CANbus speed and it will show you all of the possible BRP values.  Then it will show you what values to fill in for the remaining registers for each possible BRP value. 

No TrackBacks

TrackBack URL: http://mindbent.org/cgi-bin/mt/mt-tb.cgi/11

Leave a comment

About this Entry

This page contains a single entry by Mark Farver published on April 15, 2009 10:37 AM.

Another Disaster Recovery Plan Tip was the previous entry in this blog.

Roughing it 101. is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.24-en