cquang1
Joined: 29 Jun 2004 Posts: 1
|
Need helps for CAN controller MCP2510 |
Posted: Tue Jun 29, 2004 10:32 pm |
|
|
I am implementing a project in which a CAN network with mcp2510 from Microchip is used and my MCU is Atm32, Crystal 7.328. The CAN interface chip in use us 82250.
In my project, pins TX0RTS, TX1RTS, TX2RTS are setup as general inputs and they are connected to on/off switches. Pins RX0BF, RX1BF are confiured as general outputs and I connect them to two LEDs. Pin INT of mcp2510 is connected to pin PD2 of Atmeg32 (INT0) in order to invoke interrupts (e.g. complete transmit or receive from MCP2510).
In my project, I can initialize the CAN chip mcp2510 (Configuration mode, Normal mode or feedback mode) without problems and notes in Microchip MCP2510 Rev. Errata Sheets are considered.
I wrote a program to turn on/ turn off LEDs in a loop or turn on/off them according to switches connected to input pins TX0RTS, TX1RTS, TX2RTS. It worked very well.
And in that program, if I put the CAN chip in loopback mode, I can transmit messages to the CAN chip and receive them without problems (seen on a LCD). In that program, I used buffer 0 receive interrupt to get messages and display them on the LCD.
However, when I changed the mode of mcp2510 to normal mode, problems came up. When I transmited messages, I could not receive the messages and receice interrupts did not occur. Even though when I enabled transmit inteerupt of MCP2510, no complete transmit interrupt happened too.
As well known, the CAN chip mcp2510 uses SPI to interface with the MCU and I think my SPI driver is OK as I have applied it for many other projects with success. In my program, I did follows flow char diagram in MCP2510 datasheet and some other application notes on MCP2510. Checking TXREQ bit in TXBnCTRL register was done. In the interrupt routine that serves interrupt events from MCP2510 (e.g. compelete transmit interrupt, receive interrupt .. ), I cleared coresponding flag bits (as such RX0IF, TX0IF ...). For other things like crystal clock, timing bit ..., I think they are OK as I closely followed the MCP2510 datasheet, MCP2510 Rev. Errata Sheet, and the note "An In-Deep Look at the MCP2510" and the system could comunicate each other well in loopback mode.
So could any one with experience in that CAN chip give some advice to solve that problem and tell me a way to test my system. I know the Microchip CAN Kit is good but it is beyond my budget. My thinking is in the normal mode, can I use only on CAN chip to test the system.
Thank a lots and really look forward to get your replies |
|