There is also the issue of the clock setting.
SerMon cranks the PLL for you, so you must set the PLL up yourself.
speed the frequency of the xtal 4,8 or 16.
void PLL_Init(byte speed)
{
// PLLCLK = 2 * OSCCLK * (SYNR + 1) / (REFDV + 1)
// We want OSCCLK * (SYNR + 1) / (REFDV + 1) to be 24
if( 16 == speed )
{
SYNR = 0x02; // 16/(1+1) * (2+1) = 24
REFDV = 0x01;
} else if( 8 == speed )
{
SYNR = 0x02; // 8/(0+1) * (2+1) = 24
REFDV = 0x00;
} else if( 4 == speed )
{
SYNR = 0x05; // 4/(0+1) * (5+1) = 24
REFDV = 0x00;
}
else
return;
CLKSEL = 0x00;
PLLCTL = 0xD1; // Turn on PLL Clk
while((CRGFLG&0x08) == 0) // Wait for PLLCLK to stabilize.
;
CLKSEL_PLLSEL = 1; // Switch to PLL clock
}