Problem with Mailbox in uCOS

Hello everyone,

We are using uCOS for our application. We need to read data from the UART. So we have an UART Rx interrupt for this. In the ISR, we are using a mailbox to post message to the processing task. The processing task is Pending on the mailbox using OSMboxPend( ) . When we do this we are loosing some data because of the limited FIFO size. The FIFO size is 16 bytes and the baud rate for data transmission is 9600.

When we processed the data within the ISR (ie without using mailbox), we were not loosing any data. But its not a good idea to process the data inside the ISR.

Could anyone suggest a better way to deal with this problem.

Regards, R a n j i t h

Reply to
Ranjith
Loading thread data ...

I would suggest that you store received data into software buffer in your ISR and notify processing task that there is some data in that buffer...And at the end of ISR re-check UART buffer, to see if any character arrived during ISR processing. Worked nicely on several apps...

regards

Dejan

Reply to
Dejan Ðurdenic

The easiest way is to increase your software buffering between your ISR and application. I recommend implementing a FIFO of sufficient size, then having the ISR insert at the head and the application removes from the tail. The ISR signals the application at whatever condition you want:

1) any character added 2) specific character added, e.g., CR 3) certain number of characters

I have used this in a system with four serial ports and no problems. In my case, I defined a general mechanism for the application to specify the wakeup condition. The application layer also called a port initialization that took a buffer address for the FIFO and the size.

For the application side, I would wait for the activation, zero out the activation semaphore with OSSemAccept(), then process all available characters before waiting on the semaphore again.

Thad

Reply to
Thad Smith

As far as I know, a Mailbox has no FIFO per se. It can handle one pointer sized object at a time. If a new object is inserted before the previous one is removed, one will be lost. A Message Queue might be a better choice. It can handle multiple pointer sized objects. That way occational backups can be tolerated without loss of data.

Doug

Reply to
Doug Dotson

Thanks for your suggestions. Finally i could get the things working. I had FIFO level interrupt generator which i used to trigger this event. Things are working fine so far.

Also I was not trying to send any valid data thru the mailbox.

Regards, Ranjith

Reply to
Ranjith

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.