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.
Hello,
i'm using keil 3.05 evaluation, its my first experience with this tool. Normally i found in other tools a struct inside the .h of the uproc. In this case i found just a define.
#define PCON (*((volatile unsigned char *) 0xE01FC0C0))
trying to create a structure, i dont know how to set the struct mem position. I've tried this code bellow without sucess.
/* Cria os bits da estrutura */ struct { unsigned int PLLE : 1; unsigned int PLLC : 1; unsigned int NotUsed : 6; } PCONbits __at 0xE01FC0C0;
i'll have this libs with the full version of keil tools?
thanks! Jose
I agree with Per regarding the avoidance of using bitfields. That said, you can do it quite similarly to the char PCON macro version.
#define PCON_BITS (*(volatile struct PCONbits*)0xE01FC0C0) struct PCONbits {unsigned PLLE:1, PLLC:1, NotUsed:6;}; PCON_BITS.PLLE = 0;
If you write a PC program that generates an output file, then it is important that the output file has a file format that you may always be able to read again.
If the file is binary, and you make use of bit fields, then a compiler change may make the recompiled code unable to read back the data.
Hence my note about output files. But the problem is similar for embedded systems if you store configuration in EEPROM or FLASH memory and support firmware updates.
If you change (or upgrade) the compiler and then rebuild the application, then you can not be sure that the recompiled application will read back the same bit-field contents from EEPROM or FLASH.
This solution with macros can help me,
thanks!