<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Continuation of thread 22624....application of mailbox</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/31650/continuation-of-thread-22624-application-of-mailbox</link><description> 
hey guys, 
after a lot of guidance &amp;amp; iterations, i a code that typecast the
data as pointer and pass it via mailbox. 
all was well upto one year. but yesterday, while testing, i found out
that i receive a 0x00 from uart, which i dnt get into my rx_buf</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Continuation of thread 22624....application of mailbox</title><link>https://community.arm.com/thread/120269?ContentTypeID=1</link><pubDate>Thu, 20 Mar 2014 02:21:03 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:69d12896-eb3b-4dda-9f53-1fdcde305609</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
The mailbox functions are just designed to distribute a pointer
between sender and receiver. They don&amp;#39;t care about the contents of
the pointer.&lt;/p&gt;

&lt;p&gt;
When you move large data, then you have some form of array or pool
of mails of a suitable type and send the pointer to that mail. And
the receiver releases the mail back to the pool to be reused.&lt;/p&gt;

&lt;p&gt;
But a character is so small that it fits in the memory needed for
a pointer. So the program do not need to invest in a pool of
&amp;quot;character mails&amp;quot; and have the sender allocate a &amp;quot;character mail&amp;quot; and
send the pointer to this single-character mail. And the receiver need
not pick up a pointer to a one-character mail, process the single
character and then release this single-character mail back to the
pool. One important thing here is that allocating and releasing mails
from the memory pool requires a lock mechanism which adds to the
amount of work needed.&lt;/p&gt;

&lt;p&gt;
In short - you get a bit smaller code that consumes less memory
and less CPU time. This obviously assuming that the UART sends one
character at a time.&lt;/p&gt;

&lt;p&gt;
If using the FIFO functionality of the UART, then it might be more
efficient to actually use a pool of mails - but each mail being able
to store a character count, and multiple characters - maybe as many
as one FIFO length. So the UART can allocate a single mail, and then
clear out the receive FIFO and then post this single mail with maybe
1-16 characters.&lt;/p&gt;

&lt;p&gt;
In the end, it&amp;#39;s a question of figuring out what is best matching
the program needs. There are seldom just one possible solution.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuation of thread 22624....application of mailbox</title><link>https://community.arm.com/thread/107571?ContentTypeID=1</link><pubDate>Thu, 20 Mar 2014 01:50:27 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:584621f5-0a60-4721-882e-b8ad3426a406</guid><dc:creator>Ash J</dc:creator><description>&lt;p&gt;&lt;p&gt;
i wrote the modified code as&lt;/p&gt;

&lt;pre&gt;

// in the interrupt routine
if ((tmp == UART_IIR_INTID_RDA))        // Receive Data Available or Character time-out
{
        *prx = UART_ReceiveByte(DISPLAY_PORT_UART);

        if (isr_mbx_check (&amp;amp;MailDisplay) != 0)
                isr_mbx_send(&amp;amp;MailDisplay, (void *)prx);
}



//in the receive task
void *prx;
...

os_mbx_wait(&amp;amp;MailDisplay, &amp;amp;prx, 0xFFFF);
data = *(uint32_t*)prx;

&lt;/pre&gt;

&lt;p&gt;
what is the advantage of passing the data typecasted as pointer
[using (0x0100 | byte)]?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuation of thread 22624....application of mailbox</title><link>https://community.arm.com/thread/93143?ContentTypeID=1</link><pubDate>Thu, 20 Mar 2014 00:17:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:af84f8d3-5f5b-4f75-99ae-972546f65f67</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
The UART receives bytes.&lt;/p&gt;

&lt;p&gt;
The mailbox pointers are clearly larger than bytes.&lt;/p&gt;

&lt;p&gt;
So you can use (0x0100 | byte) to send your bytes. This makes sure
that the full byte range can be sent without looking like a NULL
pointer. And it&amp;#39;s easy to strip out that extra bit when converting
back to a byte again.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuation of thread 22624....application of mailbox</title><link>https://community.arm.com/thread/62661?ContentTypeID=1</link><pubDate>Wed, 19 Mar 2014 22:38:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f4a42e10-521d-4715-9569-49c3397b98e1</guid><dc:creator>Ash J</dc:creator><description>&lt;p&gt;&lt;p&gt;
after a lot of guidance &amp;amp; iterations, i implemented a code
that typecast the data (received on uart) as pointer and pass it via
mailbox.&lt;br /&gt;
all was well upto one year. but yesterday, while testing, i found out
that i receive a 0x00 from uart, which i dnt get into my rx_buf.
typecasting 0x00 to a pointer results to a NULL POINTER.&lt;/p&gt;

&lt;p&gt;
Just wanted to bring into notice this cautionary remark.&lt;/p&gt;

&lt;p&gt;
The implemented code, (now requires modification):&lt;/p&gt;

&lt;pre&gt;
if ((tmp == UART_IIR_INTID_RDA))       // Receive Data Available or Character time-out
        {
                data = UART_ReceiveByte(DISPLAY_PORT_UART);

                if (isr_mbx_check (&amp;amp;MailDisplay) != 0)
                        isr_mbx_send(&amp;amp;MailDisplay, (void *)data);
        }
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>