Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/03/04 05:01
Read: times


 
#61810 - RE: AT89CC01 CAN handler ALL messages
Responding to: ???'s previous message
Hi Bert,

First off, in case there are any differences, keep in mind that I've been working with the CC03...should be the same, but I haven't compared datasheets to be sure.

Also, I'm at home at the moment, so I'm doing this by memory.

As I read the datasheet, you should be able to select a channel (using CANPAGE) then set the CANIDTx and CANIDMx SFR so that any incoming frame is received. See the (very abbreviated) description of Acceptance Filtering in the data sheet. Enable the interrupt, and when the interrupt occurs check CANSTCH to determine which type of interrupt occurred (you're looking for RXOK). The demoboard software gives a good example of how to check for which channel caused the interrupt...(basically has the ISR code that is only outlined in the datasheet). Then it's a matter of successivly reading CANMSG to read out the 8 data bytes of the message (assuming you left the setup bit alone which defaults the autoincrement of the byte pointer). Reenable the interrupt to get ready for the next frame.

You're interested in CAN A, not CAN B, right? This means you only have to set up 11 bits for the ID and mask, versus 29 bits required for CAN B.

Don't forget to take a look at the CAN bootloader source code, that's another piece of example code. It's set up for CAN A.

I don't know which compiler you use. The software is set up for Keil, and unfortunately I use IAR so I've have to translate quite a few little things that get in the way of understanding what the example code is really doing. I mentioned French embedded in the code (example: RazAllMailbox(), would you automatically think ClearAllMailbox()? I didn't!). The biggest obstacle to reverse engineering the code (required because the documentation doesn't really explain what it's doing) is the fact that the author just *loves* macros. Macros within macros. It's pretty close to write-only code, so you will have to spend a lot of time flipping back and forth between assorted header files. But if you keep at it, the fog will eventually clear. I've also gotten some assistance from Atmel in explaining some things.

The CAN Monitor demo software should be pretty close to what you're looking for, that's where I'd start. Too bad Atmel doesn't have the source code for their CAN dongle.

Dennis

List of 10 messages in thread
TopicAuthorDate
AT89CC01 CAN handler ALL messages            01/01/70 00:00      
   RE: AT89CC01 CAN handler ALL messages            01/01/70 00:00      
      RE: AT89CC01 CAN handler ALL messages            01/01/70 00:00      
         RE: AT89CC01 CAN handler ALL messages            01/01/70 00:00      
            RE: AT89CC01 CAN handler ALL messages            01/01/70 00:00      
               RE: AT89CC01 CAN handler ALL messages            01/01/70 00:00      
                  RE: AT89CC01 CAN handler ALL messages            01/01/70 00:00      
                     RE: AT89CC01 CAN handler ALL messages            01/01/70 00:00      
                        RE: AT89CC01 CAN handler ALL messages            01/01/70 00:00      
                           RE: AT89CC01 CAN handler ALL messages            01/01/70 00:00      

Back to Subject List