hi, 1'm using the RTX51Tiny and am trying to implement a "mailbox"-like function to allow tasks to intercommunicate. The core structure of my program looks like this: //startup.a51 has been modified for //small reentrant stack //prototype void WriteMailBox(unsigned char NewData) small reentrant; unsigned char ReadMailBox(void); //mailbox variable unsigned char MailBox; //accesor function to mailbox void WriteMailbox(unsigned char NewData) reentrant { MailBox = NewData; } unsigned char ReadMailBox(void) { return(MailBox); } The problem arises when I try to call the WriteMailbox function in an interrupt service routine. The mailbox is not updated when the isr exits- this shows when another function calls ReadMailBox and the data dosn't match. I'd appreciate any form of help/pointer/comment. Thanks in advance!
Try declaring your MailBox variable as volatile.
Try this:
#pragma NOAREGS //accesor function to mailbox void WriteMailbox(unsigned char NewData) reentrant { MailBox = NewData; }
Declaring the variable as volatile worked fine as long as the function isn't declared as reentrant. Thanks for the pointer. :)
The variable still doesn't get updated. Thanks for the pointer :)