View Single Post
Old 01-20-2011, 01:34 PM   #4247 (permalink)
EcoModding Apprentice
Join Date: Nov 2010
Location: Annapolis
Posts: 159
Thanks: 0
Thanked 32 Times in 27 Posts
Originally Posted by MPaulHolmes View Post

Oh ya, it was a dspic30f4011. I might swap it out to have the atmega168 in there, and dump the CAN right into the recycling bin, or you could use DJ Becker's sneaky way of including it still.
My MCP2515 CAN-OBD code "works great for me", and I wrote that section so that it could drop right into the Cougar firmware.

It took a while to get working, but it should be easy enough to understand and extend the message part of the code.

Most of my debugging problems were related to the clock. I was prototyping on a solderless breadboard. I thought I would avoid crystal capacitive loading problems by using a clock from the AVR. Hilarity ensued.

You can avoid all of that, and many hours of debugging, by just using a 16MHz crystal.

(I initially thought that I could clock the chip with the SPI clock, avoiding a real clock until we needed to transmit on the wire. Not even close. The chip seems to need an independent, symmetrical clock to work correctly. The Arduino board dead-ends the CLKOUT pin, so I generated a 8MHz clock with a timer "counting up to zero". But I initialized with 0, so it counted to 0xFFFF the first time, resulting in the CAN controller not being detected but running fine later(!). I built a whole elaborate interactive debug program that timed each operation. It only told me that a reset reliably took about 3.2 usec. First time. Every time. No matter what. Only then did I figure out what was happening.)
  Reply With Quote