futz
Active Member
I'm using modified Philips AN10369 code to do async serial out on my LPC2148. But I'm a bit confused. Using the formula (and a baudrate calculator I found on the NXP site) to find U0DLL, I get a number that gets me approximately 93750 baud, instead of my desired 9600.
The formula is as follows:
Required baud rate= VPB clock/ (16 * Divisor value)
If I hadn't had my Saleae Logic (with autobaud feature - LOVE IT!!!
) I'd never even get close. By trial and error changing the number, recompiling and grabbing data with Logic I quickly changed the number to the correct U0DLL=0xc3, which gives me 9615 baud. Works perfect.
What I don't understand is why this is. The PLL is not enabled. The chip runs on a 12MHz crystal. Default peripheral clock is 1/4 of system clock, so it should be 3MHz, right?
I'm missing something. Just not sure what yet...![Confused :confused: :confused:](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
EDIT: More calculating tells me I'm running PCLK at 30MHz, though I have no idea how that's even possible (yet) without the PLL being involved.
Ha! The probes just barely fit the pins on this 16-SOIC:
**broken link removed**
The code:
The Logic's output for one line:
![bleh.jpg bleh.jpg](https://www.electro-tech-online.com/data/attachments/21/21300-0c6e7c3e2ec36f09ff62eea37538a596.jpg)
The formula is as follows:
Required baud rate= VPB clock/ (16 * Divisor value)
If I hadn't had my Saleae Logic (with autobaud feature - LOVE IT!!!
What I don't understand is why this is. The PLL is not enabled. The chip runs on a 12MHz crystal. Default peripheral clock is 1/4 of system clock, so it should be 3MHz, right?
I'm missing something. Just not sure what yet...
EDIT: More calculating tells me I'm running PCLK at 30MHz, though I have no idea how that's even possible (yet) without the PLL being involved.
Ha! The probes just barely fit the pins on this 16-SOIC:
**broken link removed**
The code:
Code:
#include "LPC214x.h"
void init(void);
void delay_ms(int);
int main()
{
int i;
char c[]="Futz's LPC2148";
init();
while(1){
i=0;
while(c[i]){
U0THR=c[i];
i++;
}
U0THR=0x0a;
U0THR=0x0d;
while(!(U0LSR && 0x40));
delay_ms(250);
}
}
void init()
{
PINSEL0=0x05;
U0FCR=0x07; //enable and clear FIFOs
U0LCR=0x83; //8-N-1, enable divisors
U0DLL=0xc3; //9600 baud (9615)
U0DLM=0x00;
U0LCR=0x03; //8-N-1, disable divisors
}
void delay_ms(int x) //this isn't accurate right now
{ //it's just a rough delay
int a,b;
for(a=0;a<x;a++){
for(b=0;b<3000;b++);
}
}
The Logic's output for one line:
![bleh.jpg bleh.jpg](https://www.electro-tech-online.com/data/attachments/21/21300-0c6e7c3e2ec36f09ff62eea37538a596.jpg)
Last edited: