void SYSCLK_Init (void)
{
unsigned char temppage;
unsigned int n; //local variable used in delay FOR loop.
temppage=SFRPAGE;
SFRPAGE = CONFIG_PAGE; //switch to config page to config oscillator
OSCXCN = 0x67; //16M
for (n=0;n<255;n++); //delay about 1ms
while ((OSCXCN & 0x80) == 0); //wait for oscillator to stabilize
CLKSEL |= 0x01; //switch to external oscillator
SFRPAGE=temppage;
}