Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: CAN reception
PostPosted: Mon Nov 22, 2010 5:21 pm 
Offline

Joined: Mon Nov 22, 2010 2:09 pm
Posts: 3
Hi all!!

We are developing an application that sneds & receives messages through CAN. We are using the evaluation kit AT91SAM7X-EK 512. And we have based on the CAN basic sample application available at atmel website. So, we are using that driver and it is working fine, but the problem comes when an external hardware is sending to the evaluation board a set of packages with the same ids in a short period of time(around 36 packets in less than 1 second), and what is happening is that we get the first 6 values but we are missing the rest (around 25 more or less).

The configuration of the mailboxes we have is the following: from 0 to 6 configured as reception mailboxes with no acceptance mask (so we can get any message from CAN), we also tried with the latest in reception and overwrite mailbox (number 6), but in that case we get the first five packets and the latest one, so we are missing the others in the middle.
And particularly, waht we are doing is that we are getting the handler for CAN called CAN_Handler, the same as the one in the exmaple, and we store the packet received so we can process it later, and we are able to receive more packets, but it is not working 100% as we are losing some of them.

We think that the problem could be that the mailboxes are not free when we get more packets and that is why the handler is not triggered and so we are losing the packets. We also thought in the bus speed (configured for 1 Mb), but we connected a CAN sniffer, and we can see all the packets, so that is not the problem. So, does anybody know what could be the problem??

We would appreciate any information,

Regards,

Javier.


Top
 Profile  
 
 Post subject: Re: CAN reception
PostPosted: Mon Nov 22, 2010 6:17 pm 
Offline

Joined: Mon Nov 22, 2010 2:09 pm
Posts: 3
Hi all again,

Sorry, we found the bug, we wasn't changing the CAN_MBx.CAN_MB_MCR values to AT91C_CAN_MTCR and we also had a printf in the handler code, both things have made it possible to receive every single packet,

Regards


Top
 Profile  
 
 Post subject: Re: CAN reception
PostPosted: Mon Nov 22, 2010 7:01 pm 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
Avoid putting diagnostic print/trace messages into the CAN_Handler(), this will slow it's responsiveness significantly. If you want to gather metric (ie mailboxes, messages received, etc), use counters and flags which you can print out in you foreground/idle task/loop.

If you are missing messages because you are not servicing them quickly enough, you need to analyze the code flow, and figure out how to quickly copy the messages/payloads into your own buffers for processing in a lower priority worker task, and mark the CAN mailboxes as available for new messages (AT91C_CAN_MTCR). The objective is to service the mailboxes quickly and leave.

Edit : Missed your response while formulating my own. The example code has lots of trace messaging.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


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 post attachments in this forum

Search for:
Jump to: