The CANTA register indicates when a message was sent but it doesn't indicate that a mailbox is ready after power up. The demo code does this:
do
{
ECanaShadow.CANTA.all = ECanaRegs.CANTA.all;
} while(ECanaShadow.CANTA.bit.TA25 == 0 ); // Wait for TA5 bit to be set..
This code assumes that nothing was written to the mailbox to begin with and waits until it is sent before it moves on to write more data.
I can't wait for the bit and I can't necessarily assume it is empty to begin with. Seems there should be a flag to indicate the mailbox is empty. Perhaps I am missing something. What is the best practice for this?
To get around it in my code, I always check if the CANTA bit is set before writing to the mailbox. I get the bit set initially by writing some arbitrary message after power up. I don't particularly like this solution. What is the best way to handle this?
Thanks