View previous topic :: View next topic |
Author |
Message |
dara hayes
Joined: 26 Nov 2003 Posts: 12 Location: Ireland
|
Error handling routine CAN BUS |
Posted: Thu Sep 09, 2004 5:06 am |
|
|
Hello
am looking for tips on how to handle errors such as INVALID ID and
CAN ERROR while sending or receiving can frames
using the 258 device and about 10 nodes on short distance 1mBit bus
I currently just have simple PRINTF's in the error Interrupts and once either an
CAN_ERROR or INVALLID_ID occur they just repeat for ever untill I reboot the nodes , what is the correct way to handle an INVALLID ID,
I read some where that INVALID ID may not need attention but I know it does because Im finished when ever I get an error due to complete lack
of error handling, newbie to can but have managed to get my project complete but not at all bullet proof yet ....
I am using interrupt driven RS232 receive and interrupt driven CAN TX RX to connect about 8 -10 nodes across a high speed short distance bus
but I have no error handling and as a result bomb out as soon as I get an error, would appreciate a point in the right direction as to how to handle these two errors ,tracked down the dale herman ported code on his execellent usb/can project but he doesnt use interrupts and there no pointers to error handling there, have read and reread the pdf docs on PIC18 started can bus project using the CCS can kit
but havent seen the light yet re CAN_ERROR or INVALID_ID
Also what is the exact situation on a lost arbitration error does one need to resend the frames that havent gone or does the can engine do this for you at a later time.
Thanks
Dara Hayes |
|
|
Trampas
Joined: 04 Sep 2004 Posts: 89 Location: NC
|
|
Posted: Thu Sep 09, 2004 6:49 am |
|
|
Dara,
I have not used the CAN bus yet, but will be soon.
I think you might want to have some handshaking between nodes when the data is crtical. For example you can do something like Xmodem where you send data and the host mush acknoledge the data packet. Thus when you get an error you would send the NAK symbol to sender to indicate you had a problem. Then you could enter a timer which after timing out would send another NAK or data request. Then finally if the timer is called xxx number of times you assume remote is hosed.
I am not sure if this was what you were looking for or not.
Trampas |
|
|
dara hayes
Joined: 26 Nov 2003 Posts: 12 Location: Ireland
|
Can error handling |
Posted: Thu Sep 09, 2004 7:57 am |
|
|
thanks your reply
I got a time stamp and a terminator chars in the tail of each message so I know when messages are not complete, but the errors Im talking of are physical interrupt events which occur as a direct result of an error occuring with the can bus or the frame being received
I need to sort out how to handle them locally
Dara |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Sep 09, 2004 12:08 pm |
|
|
Quote: |
am looking for tips on how to handle errors such as INVALID ID and
CAN ERROR while sending or receiving can frames |
What driver are you using ? I did a text search on all source files
in the CCS compiler directories and could not find either of those
symbols. |
|
|
dara hayes
Joined: 26 Nov 2003 Posts: 12 Location: Ireland
|
CCS CAn driver |
Posted: Fri Sep 10, 2004 2:55 pm |
|
|
sorry the two errors I refer to are the can error interrupt and the IRx
as follows
#INT_CANERR // can error
void do_canerror(void)
{ printf("\r\nCAN_ERR");}
#INT_CANIRX // invalid message received
void do_canirx(void)
{ printf("\r\nINVALID_MSG"); }
Can error and invallid message error
Dara hayes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Sep 10, 2004 4:28 pm |
|
|
Quote: | The two errors I refer to are the CAN error interrupt and the IRx.
#INT_CANERR // can error
void do_canerror(void)
{ printf("\r\nCAN_ERR");}
#INT_CANIRX // invalid message received
void do_canirx(void)
{ printf("\r\nINVALID_MSG"); } |
For #INT_CANERR:
Microchip appnote AN215 has a flow chart and source code (in assembly)
for a CAN Error interrupt handler. You should be able to translate the
ASM code to C. See pages 4, 9, and 16 in this document:
http://ww1.microchip.com/downloads/en/AppNotes/00215b.pdf
For #INT_CANIRX:
See the Microchip PIC18 Reference Manual for the CAN module,
in section 22.9.6.3 Invalid Message Received (page 55) and also
section 22.9.7.3.1 Invalid Message Received Interrupt (page 58):
http://ww1.microchip.com/downloads/en/DeviceDoc/39522.pdf |
|
|
|