We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi All. I'm becoming more familiar with C51's various memory models, but I could use some confirmation on one issue. Here's a code snippet:
char CODE_B = 'B'; char CODE_C = 'C'; ... void TaskShow( void ) { OStypeMsgP msgP; InitPORT(); PORT = 0x00; for (;;) { OS_WaitMsg(MSG_UPDATE_PORT_P, &msgP, OSNO_TIMEOUT, TaskShow1); if ( *(char *)msgP == CODE_C ) { PORT &= ~0xFE; PORT |= ( counter >> 8 ) & 0xFE; } else PORT ^= 0x01; } }
if ( *(char xdata *)msgP == CODE_C ) {
Andrew, I'm afraid I don't have much to add here. I'd have done the message object a bit differently to avoid the 8051 data space specifier conundrum but as I'm sure you're well aware, there's not much you can do with a typedef once you've declared it except use it. For the message object I'd simply forgo the pointer version and supply the base type letting user create a pointer from it. E.g.
typedef enum MsgTypes { MSG_COMPLEX, MSG_A, MSG_B, MSG_C, NUM_MSGS } MsgTypes; typedef struct o_complex { int var; char arr[5]; } o_complex; typedef struct o_msg { MsgTypes type; union MsgBody { o_complex complex; unsigned long apple; unsigned int butter; unsigned char cheese; } body; } o_msg; int main(void) { /* Pointer resides in IDATA but points only to DATA space */ o_msg idata * data pMsg; pMsg->type = MSG_A; pMsg->body.cheese = 'a'; /* blah, blah, blah... */ for (;;); return 0; }
Ahem, off-line is tough without an email address, eh? mark@embeddedfw.com
maybe we should take it off-line That'd be a shame. Then all of us Salvo users couldn't see what you guys are up to ;-) I've always found it beneficial to follow a problem as it is worked through to its eventual solution.
I just don't want to turn Keil's website into a Salvo discussion forum, they have their own already. Regards, - Mark
I just don't want to turn Keil's website into a Salvo discussion forum, they have their own already. Agreed. This is Keil's web space, after all. I'm pretty happy with the way we do message pointers -- anything more explicit invariably leads to cross-platform portability problems and increased maintenance headaches. It does work well, once users get the hang of it. And it can be quite efficient. Thanks again, Mark, for your help and interest in my original query. It has helped me in my understanding of the pointer situation with Cx51. Regards,