I am getting compiler error for below given function written to read the MAC (IEEE) address of TI CC2430
( error C141: syntax error near 'code' ... & ... error C141: syntax error near ')' )
// // Keil workaround #define __code code; //IEEE MAC address in flash memory #define MAC_FLASH_ADDR (0x3FFFF-7) uint8_t IEEE_MAC[8]; void ReadMAC(void) { bspIState_t state; uint8_t fmaptmp; uint8_t i; uint8_t code *flash; BSP_ENTER_CRITICAL_SECTION(state); while (FCTL & BIT7); //wait for the flash controller to be ready fmaptmp = FMAP; FMAP = MAC_FLASH_ADDR >> 15; flash = (code uint8_t *)((MAC_FLASH_ADDR & 0xFFFF) | 0x8000); Compiler Error for(i=0; i<8; i++) { IEEE_MAC[i] = flash[7-i]; } FMAP = fmaptmp; BSP_EXIT_CRITICAL_SECTION(state); }
I am not sure where I am going wrong any help would be appreciated. Thanks in Advance
// // Keil workaround
That hints at this being an attempt to move code from one compiler to the other without really understanding the particularities of either. And that's exactly where your code fails. The pointer cast is syntacically incorrect. Get back to the documentation and find out how to spell memory-space specific pointer types in Keil.
the workaround is
flash = (uint8_t code*)(MAC_FLASH_ADDR);
Why do you call it a "workaround" ?
Surely, it's just a matter of correct syntax - no "workaround" ?!