CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Error handling routine CAN BUS

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
dara hayes



Joined: 26 Nov 2003
Posts: 12
Location: Ireland

View user's profile Send private message

Error handling routine CAN BUS
PostPosted: Thu Sep 09, 2004 5:06 am     Reply with quote

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

View user's profile Send private message MSN Messenger

PostPosted: Thu Sep 09, 2004 6:49 am     Reply with quote

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

View user's profile Send private message

Can error handling
PostPosted: Thu Sep 09, 2004 7:57 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Sep 09, 2004 12:08 pm     Reply with quote

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

View user's profile Send private message

CCS CAn driver
PostPosted: Fri Sep 10, 2004 2:55 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Sep 10, 2004 4:28 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group