Thanks for your comments on the issue.
1-I have tried the define suggestion.
It seems to work up and until I get to a point where
my original register name includes periods which the
compiler possibly dislikes.
Original source code:
Flash.fclkdiv.byte = Flash.fclkdiv.byte | fclk_val| FDIV8;
Attempt to define:
#define Flash.fclkdiv.byte FCLKDIV
(FCLKDIV is how PE defines this particular register.)
This line compiles OK, but later on when the substitiution needs
to take place, there is a a complaint about '}' missing error C2801,
and fclkdiv not declared, error C1815.
I have hardcoded this instead, and tried the same method with FDIV
which works OK. The only difference between them seem to be the
periods in the "Flash.fclkdiv.byte" line.
2-I also dislike ignoring warnings and errors.
I want clean compiles/links.
The define method seems to be best, if I could make it work.
Can you figure out what is wrong?
Thanks,
Anders
Source cutout follows:
// Attempt to redefine offending defintions, but it seems the periods are disliked.......
#define Flash.fclkdiv.byte FCLKDIV
#define FDIV8 PRDIV8
extern DoOnStack(unsigned int *far address);
//*****************************************************************************
//* Function Name : Flash_Init
//* Description : Initialize Flash NVM for HC9S12 by programming
//* FCLKDIV based on passed oscillator frequency, then
//* uprotect the array, and finally ensure PVIOL and
//* ACCERR are cleared by writing to them.
//*
//*****************************************************************************
void Flash_Init(unsigned long oscclk)
{
unsigned char fclk_val;
unsigned long temp;
/* Next, initialize FCLKDIV register to ensure we can program/erase */
temp = oscclk;
if (oscclk >= 12000) {
fclk_val = oscclk/8/200 - 1; /* FDIV8 set since above 12MHz clock */
Flash.fclkdiv.byte = Flash.fclkdiv.byte | fclk_val| FDIV8;
// FCLKDIV = FCLKDIV | fclk_val| FDIV8; // WORKS!!!!!!!!!!
// FCLKDIV = FCLKDIV | fclk_val| FCLKDIV_PRDIV8; // WORKS!!!!!!!!!!
}
else
{
fclk_val = oscclk/8/200 - 1;
Flash.fclkdiv.byte = Flash.fclkdiv.byte | fclk_val;
}
Flash.fprot.byte = 0xFF; /* Disable all protection (only in special modes)*/
Flash.fstat.byte = Flash.fstat.byte | (PVIOL|ACCERR);/* Clear any errors */
}