I am running the logomatic at a lower clock speed to 12 mhz to reduce power usage. This is working, the power consumption is down and a light blinks at the correct rate. (code below)
the PLL_int puts it into lower speed (slow).
At 60mhz Everything works fine and I can read the debug text output without any problem.
At 12 mhz, I also configure the uart0 to take the change in pclk into account. (code also below) It outputs nothing but garbage, I have tried setting to different baud rates with the same result.
Can anyone tell me what I am missing? I believe that I have faithfully followed the data sheet.
Thanks,
Stefan
void PLL_init(int speed) // sets clock speed
{
if(speed==fast){PLLCFG=0x24;} // Setting Multiplier(5) and Divider(4) so 5xosc (12mhz) = 60 mhz
else{PLLCFG=0x60;VPBDIV = 0x1;} //Setting Multiplier(1) and Divider(8) 1xosc = 12mhz: pclk = cclk
feed();
PLLCON=0x1; // Enabling the PLL
feed();
while(!(PLLSTAT & PLOCK)) ;// Wait for the PLL to lock to set frequency
PLLCON=0x3;// Connect the PLL as the clock source
feed();
}
//***********************************************************
void setuart(int speed) //sets up UART0
{
if(speed==fast)
{
U0LCR = 0x83; // 8 bits, no parity, 1 stop bit, DLAB = 1
U0DLM = 0x00; //msb = 0
U0DLL = 0x20; //lsb = 32
U0FCR = 0x07; // enable and reset
U0LCR = 0x03; // 8 bit character length
VICIntEnClr = 0x00000040;
U0IER = 0x00;
}
else //initialize uart0 115200 buad 12mhz
{
U0LCR = 0x83; // 8 bits, no parity, 1 stop bit, DLAB = 1
U0DLM = 0x00; //msb = 0
U0DLL = 0x6; //lsb = 6
U0FDR = 0xC1; //fract divider divaddval(3:0) = 1 & mulval(7:4) = 12
U0FCR = 0x07; // enable and reset
U0LCR = 0x03;
VICIntEnClr = 0x00000040;
U0IER = 0x00;
}
}