Hi Chuck, Well done on the progress. Good to hear you went straight to CAN. I have one comment on using interrupts that you might need to be aware of. This won't apply if all your code for the MCP2515 is done in the interrupt handler and you are not using SPI for anything else. The issue you have is when you want to send CAN data. If you have interrupts setup for receive, which is the most likely case, then you can't be checking the MCP2515 in any of your foreground code to send data unless you have some form of critical section around the SPI stuff. My first attempt at writing this was long and messy, I'll try again. The reason for his is that if you might be in the middle of sending an SPI command to the MCP2515 in your foreground code to setup the register to read or write to. Then as you are about to read the register with the next command the interrupt handler fires and changes the register pointer to get the received data and then it exits the interrupt handler. Now when you came back out, your foreground task would be looking at the same register the interrupt handler just accessed and not the one you wanted or had previously setup. The issue I faced with the controller was the fact that I didn't get a transmit interrupt until I actually sent something and it fired the interrupt when that data was transmitted. I ended up switching off INTERRUPTS whilst I was writing to the device which was only when I needed to send data which on the design at the time was once per second. It only had to be disabled for the SPI calls. Hope this info helps. Dave... --- Very funny Scotty, now beam down my clothes!!! --- From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf Of Chuck Hackett Sent: 05 January 2011 05:53 To: AVR-Chat@yahoogroups.com Subject: [AVR-Chat] Project status report and question ... - I am now writing the firmware. My two challenges have been that I am using FreeRTOS for the first time and, due to the recommendations of list members, I bypassed my initial plan (start with RS-485 and switch to CAN later) and went right to CAN. I included an MCP2515 CAN controller (SPI interface) and MCP2551 CAN bus driver on the board. It took me about 4 days to get the MCP2515 to cooperate - mostly due to a dumb (aren't they all?) programming error of course. On the positive side, I have lot of 'instrumentation' in place as a result of the "bug chase". I now have simple test messages (w/o interrupts) going between two controllers (over 5" of wire :-) ). In the process I have gained a basic understanding of how to work with the MCP2515 and I'm about to convert it to interrupt driven. So far I have not discovered any connections (traces) I needed that I did not include in the board design, so, so far, the boards won't have any ugly "cut/reroute" of traces. Cheers, Chuck Hackett [Non-text portions of this message have been removed]
Message
RE: [AVR-Chat] Project status report and question ...
2011-01-05 by Dave McLaughlin
Attachments
- No local attachments were found for this message.