EmbeddedRelated.com
Forums

LPC2132 Serial Communication

Started by Ryan Dawson November 14, 2008
Ok guys, I feel dumb asking y'all for help, but I am borderline going
crazy. What I am trying to do is send numbers 0 through 20 over a
serial cable to hyperterm (running on XP).

I have the phillips lpc2132. I provided the code below. What I am
not looking for a direct solution. I am looking for some hints for
when this code may go wrong (why it isn't sending to hyperterm).

What I have done:

1. Setup hyperterm to 9600 baud rate, 8 bit message, no Parity,1
Stop bit.
2. Flashed the program onto the board. There was no compilation
errors or warnings.

What happens:
1. Hyperterm shows nothing.

What I have done to troubleshoot:

1. Read 2 lpc213xx manuals on UART.
2. I have changed the values of U1LCR , U1DLL several different
times.
3. Everytime I changed the values, I tested. Still no
communication.

I believe that the main function is correct. The two things I am
worried about is the initialize function (Making sure the values are
right), and the putchar function (U1THR is being used correctly).

Can anyone point me in the right direction please.

///////Start code here\\\\\\\\\\\\\\\\\\

#include

void Initialize(void);
int putchar(int);

#define TEMT (1<<6)
#define LINE_FEED 0xA
#define CARRIAGE_RET 0xD

int main()
{
int i;
Initialize();

while(1)
{
i=0;
putchar(i);
i++;
if (i == 20) i=0;
}
}

/*************** System Initialization ***************/
void Initialize()
{
PINSEL0 = 0x00050000;
U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop
bit */
U1DLL = 97;
U1LCR = 0x03;
}

/**********Write character to Serial Port*************/
int putchar (int ch)
{

if (ch == '\n') {
while (!(U1LSR & 0x20));
U1THR = CARRIAGE_RET; /* output CR */
}
while (!(U1LSR & 0x20));
return (U1THR = ch);
}

An Engineer's Guide to the LPC2100 Series

> /**********Write character to Serial Port*************/ int
> putchar (int ch) {
>
> if (ch == '\n') {
> while (!(U1LSR & 0x20));
> U1THR = CARRIAGE_RET; /* output CR */
> }
> while (!(U1LSR & 0x20));
> return (U1THR = ch);
> }

I have not looked through your UART code, but if you want to see the numbers
coming out in HyperTerm then you need to send ASCII characters, starting
with '0' (i.e. the character zero, or integer 48), not starting with integer
0.

Regards,
Richard.

+ http://www.FreeRTOS.org
17 official architecture ports, more than 6000 downloads per month.

+ http://www.SafeRTOS.com
Certified by T as meeting the requirements for safety related systems.

Ryan,

I haven't looked at the LPC specifics of your code, but you are aware of
the fact that you send binary characters 0x00 to 0x19 to Hyperterm? Be
prepared for it to act quite fancy (if at all) with these characters.

For debuging purposes, you better use characters 0x40 and up cause this
equals to printable characters.

Just my 2 of course

Markus

Ryan Dawson schrieb:
>
> Ok guys, I feel dumb asking y'all for help, but I am borderline going
> crazy. What I am trying to do is send numbers 0 through 20 over a
> serial cable to hyperterm (running on XP).
>
> I have the phillips lpc2132. I provided the code below. What I am
> not looking for a direct solution. I am looking for some hints for
> when this code may go wrong (why it isn't sending to hyperterm).
>
> What I have done:
>
> 1. Setup hyperterm to 9600 baud rate, 8 bit message, no Parity,1
> Stop bit.
> 2. Flashed the program onto the board. There was no compilation
> errors or warnings.
>
> What happens:
> 1. Hyperterm shows nothing.
>
> What I have done to troubleshoot:
>
> 1. Read 2 lpc213xx manuals on UART.
> 2. I have changed the values of U1LCR , U1DLL several different
> times.
> 3. Everytime I changed the values, I tested. Still no
> communication.
>
> I believe that the main function is correct. The two things I am
> worried about is the initialize function (Making sure the values are
> right), and the putchar function (U1THR is being used correctly).
>
> Can anyone point me in the right direction please.
>
> ///////Start code here\\\\\\\\\\\\\\\\\\
>
> #include void Initialize(void);
> int putchar(int);
>
> #define TEMT (1<<6)
> #define LINE_FEED 0xA
> #define CARRIAGE_RET 0xD
>
> int main()
> {
> int i;
> Initialize();
>
> while(1)
> {
> i=0;
> putchar(i);
> i++;
> if (i == 20) i=0;
> }
> }
>
> /*************** System Initialization ***************/
> void Initialize()
> {
> PINSEL0 = 0x00050000;
> U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop
> bit */
> U1DLL = 97;
> U1LCR = 0x03;
> }
>
> /**********Write character to Serial Port*************/
> int putchar (int ch)
> {
>
> if (ch == '\n') {
> while (!(U1LSR & 0x20));
> U1THR = CARRIAGE_RET; /* output CR */
> }
> while (!(U1LSR & 0x20));
> return (U1THR = ch);
> }
>
>
..and what is your core clock, Plck. U1DLL, U1LCR may be wrong, also

Tim
Markus Zingg wrote:
>
>
> Ryan,
>
> I haven't looked at the LPC specifics of your code, but you are aware of
> the fact that you send binary characters 0x00 to 0x19 to Hyperterm? Be
> prepared for it to act quite fancy (if at all) with these characters.
>
> For debuging purposes, you better use characters 0x40 and up cause this
> equals to printable characters.
>
> Just my 2 of course
>
> Markus
>
> Ryan Dawson schrieb:
> >
> > Ok guys, I feel dumb asking y'all for help, but I am borderline going
> > crazy. What I am trying to do is send numbers 0 through 20 over a
> > serial cable to hyperterm (running on XP).
> >
> > I have the phillips lpc2132. I provided the code below. What I am
> > not looking for a direct solution. I am looking for some hints for
> > when this code may go wrong (why it isn't sending to hyperterm).
> >
> > What I have done:
> >
> > 1. Setup hyperterm to 9600 baud rate, 8 bit message, no Parity,1
> > Stop bit.
> > 2. Flashed the program onto the board. There was no compilation
> > errors or warnings.
> >
> > What happens:
> > 1. Hyperterm shows nothing.
> >
> > What I have done to troubleshoot:
> >
> > 1. Read 2 lpc213xx manuals on UART.
> > 2. I have changed the values of U1LCR , U1DLL several different
> > times.
> > 3. Everytime I changed the values, I tested. Still no
> > communication.
> >
> > I believe that the main function is correct. The two things I am
> > worried about is the initialize function (Making sure the values are
> > right), and the putchar function (U1THR is being used correctly).
> >
> > Can anyone point me in the right direction please.
> >
> > ///////Start code here\\\\\\\\\\\\\\\\\\
> >
> > #include
> >
> > void Initialize(void);
> > int putchar(int);
> >
> > #define TEMT (1<<6)
> > #define LINE_FEED 0xA
> > #define CARRIAGE_RET 0xD
> >
> > int main()
> > {
> > int i;
> > Initialize();
> >
> > while(1)
> > {
> > i=0;
> > putchar(i);
> > i++;
> > if (i == 20) i=0;
> > }
> > }
> >
> > /*************** System Initialization ***************/
> > void Initialize()
> > {
> > PINSEL0 = 0x00050000;
> > U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop
> > bit */
> > U1DLL = 97;
> > U1LCR = 0x03;
> > }
> >
> > /**********Write character to Serial Port*************/
> > int putchar (int ch)
> > {
> >
> > if (ch == '\n') {
> > while (!(U1LSR & 0x20));
> > U1THR = CARRIAGE_RET; /* output CR */
> > }
> > while (!(U1LSR & 0x20));
> > return (U1THR = ch);
> > }
> >
> >
>
>
Hello Ryan,

beside the already mentioned problems:

while(1)
{
i=0;
putchar(i);
i++;
if (i == 20) i=0;
}

I think you also don't want to set i to 0 every time you loop...

Otherwise i++; if(...) ...; is useless.

For beginning, try something like

while(1)
{
putchar('A');
for(i = 0; i < 1000000; i++);
}

Regards,

Martin
--- In l..., "Ryan Dawson"
wrote:
>
> Ok guys, I feel dumb asking y'all for help, but I am borderline
going
> crazy. What I am trying to do is send numbers 0 through 20 over a
> serial cable to hyperterm (running on XP).
>
> I have the phillips lpc2132. I provided the code below. What I am
> not looking for a direct solution. I am looking for some hints for
> when this code may go wrong (why it isn't sending to hyperterm).
>
> What I have done:
>
> 1. Setup hyperterm to 9600 baud rate, 8 bit message, no
Parity,1
> Stop bit.
> 2. Flashed the program onto the board. There was no
compilation
> errors or warnings.
>
> What happens:
> 1. Hyperterm shows nothing.
>
> What I have done to troubleshoot:
>
> 1. Read 2 lpc213xx manuals on UART.
> 2. I have changed the values of U1LCR , U1DLL several
different
> times.
> 3. Everytime I changed the values, I tested. Still no
> communication.
>
> I believe that the main function is correct. The two things I am
> worried about is the initialize function (Making sure the values
are
> right), and the putchar function (U1THR is being used correctly).
>
> Can anyone point me in the right direction please.
>
> ///////Start code here\\\\\\\\\\\\\\\\\\
>
> #include
>
> void Initialize(void);
> int putchar(int);
>
> #define TEMT (1<<6)
> #define LINE_FEED 0xA
> #define CARRIAGE_RET 0xD
>
> int main()
> {
> int i;
> Initialize();
>
> while(1)
> {
> i=0;
> putchar(i);
> i++;
> if (i == 20) i=0;
> }
> }
>
> /*************** System Initialization ***************/
> void Initialize()
> {
> PINSEL0 = 0x00050000;
> U1LCR = 0x83; /* 8 bits, no Parity, 1
Stop
> bit */
> U1DLL = 97;
> U1LCR = 0x03;
> }
>
> /**********Write character to Serial Port*************/
> int putchar (int ch)
> {
>
> if (ch == '\n') {
> while (!(U1LSR & 0x20));
> U1THR = CARRIAGE_RET; /* output CR */
> }
> while (!(U1LSR & 0x20));
> return (U1THR = ch);
> }
>

Thanks for all of the quick replies. This is the first time I have
posted here, and I am very impressed. Wow I guess programming late
at night is not a good idea for me. I will fix the ASCII error and
the terrible for loop I made. As for the core clock issue, I am not
sure what to do. I am unsure of what DLL does. I have read this
from a pdf.

The UART0 Divisor Latch is part of the UART0 Baud Rate Generator and
holds the value used to divide the VPB clock (pclk) in
order to produce the baud rate clock, which must be 16x the desired
baud rate. The U0DLL and U0DLM registers together form
a 16 bit divisor where U0DLL contains the lower 8 bits of the divisor
and U0DLM contains the higher 8 bits of the divisor. A `h0000
value is treated like a `h0001 value as division by zero is not
allowed.The Divisor Latch Access Bit (DLAB) in U0LCR must be
one in order to access the UART0 Divisor Latches.

But I am unsure of what this means.

Again I really appreciate the help. I was at my wit's end with
this. Pardon the cliche.
--- In l..., Timucin KANATLI wrote:
>
> ..and what is your core clock, Plck. U1DLL, U1LCR may be wrong, also
>
> Tim
>
>
> Markus Zingg wrote:
> >
> >
> > Ryan,
> >
> > I haven't looked at the LPC specifics of your code, but you are
aware of
> > the fact that you send binary characters 0x00 to 0x19 to
Hyperterm? Be
> > prepared for it to act quite fancy (if at all) with these
characters.
> >
> > For debuging purposes, you better use characters 0x40 and up
cause this
> > equals to printable characters.
> >
> > Just my 2 of course
> >
> > Markus
> >
> > Ryan Dawson schrieb:
> > >
> > > Ok guys, I feel dumb asking y'all for help, but I am
borderline going
> > > crazy. What I am trying to do is send numbers 0 through 20
over a
> > > serial cable to hyperterm (running on XP).
> > >
> > > I have the phillips lpc2132. I provided the code below. What I
am
> > > not looking for a direct solution. I am looking for some hints
for
> > > when this code may go wrong (why it isn't sending to
hyperterm).
> > >
> > > What I have done:
> > >
> > > 1. Setup hyperterm to 9600 baud rate, 8 bit message, no
Parity,1
> > > Stop bit.
> > > 2. Flashed the program onto the board. There was no compilation
> > > errors or warnings.
> > >
> > > What happens:
> > > 1. Hyperterm shows nothing.
> > >
> > > What I have done to troubleshoot:
> > >
> > > 1. Read 2 lpc213xx manuals on UART.
> > > 2. I have changed the values of U1LCR , U1DLL several different
> > > times.
> > > 3. Everytime I changed the values, I tested. Still no
> > > communication.
> > >
> > > I believe that the main function is correct. The two things I
am
> > > worried about is the initialize function (Making sure the
values are
> > > right), and the putchar function (U1THR is being used
correctly).
> > >
> > > Can anyone point me in the right direction please.
> > >
> > > ///////Start code here\\\\\\\\\\\\\\\\\\
> > >
> > > #include
> > >
> > > void Initialize(void);
> > > int putchar(int);
> > >
> > > #define TEMT (1<<6)
> > > #define LINE_FEED 0xA
> > > #define CARRIAGE_RET 0xD
> > >
> > > int main()
> > > {
> > > int i;
> > > Initialize();
> > >
> > > while(1)
> > > {
> > > i=0;
> > > putchar(i);
> > > i++;
> > > if (i == 20) i=0;
> > > }
> > > }
> > >
> > > /*************** System Initialization ***************/
> > > void Initialize()
> > > {
> > > PINSEL0 = 0x00050000;
> > > U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop
> > > bit */
> > > U1DLL = 97;
> > > U1LCR = 0x03;
> > > }
> > >
> > > /**********Write character to Serial Port*************/
> > > int putchar (int ch)
> > > {
> > >
> > > if (ch == '\n') {
> > > while (!(U1LSR & 0x20));
> > > U1THR = CARRIAGE_RET; /* output CR */
> > > }
> > > while (!(U1LSR & 0x20));
> > > return (U1THR = ch);
> > > }
> > >
> > >
> >
>
Use

UoDLM + UoDLL = (pclk / (baudrate * 16))
Ryan Dawson wrote:
>
> Thanks for all of the quick replies. This is the first time I have
> posted here, and I am very impressed. Wow I guess programming late
> at night is not a good idea for me. I will fix the ASCII error and
> the terrible for loop I made. As for the core clock issue, I am not
> sure what to do. I am unsure of what DLL does. I have read this
> from a pdf.
>
> The UART0 Divisor Latch is part of the UART0 Baud Rate Generator and
> holds the value used to divide the VPB clock (pclk) in
> order to produce the baud rate clock, which must be 16x the desired
> baud rate. The U0DLL and U0DLM registers together form
> a 16 bit divisor where U0DLL contains the lower 8 bits of the divisor
> and U0DLM contains the higher 8 bits of the divisor. A `h0000
> value is treated like a `h0001 value as division by zero is not
> allowed.The Divisor Latch Access Bit (DLAB) in U0LCR must be
> one in order to access the UART0 Divisor Latches.
>
> But I am unsure of what this means.
>
> Again I really appreciate the help. I was at my wit's end with
> this. Pardon the cliche.
>
> --- In l... ,
> Timucin KANATLI wrote:
> >
> > ..and what is your core clock, Plck. U1DLL, U1LCR may be wrong, also
> >
> > Tim
> >
> >
> > Markus Zingg wrote:
> > >
> > >
> > > Ryan,
> > >
> > > I haven't looked at the LPC specifics of your code, but you are
> aware of
> > > the fact that you send binary characters 0x00 to 0x19 to
> Hyperterm? Be
> > > prepared for it to act quite fancy (if at all) with these
> characters.
> > >
> > > For debuging purposes, you better use characters 0x40 and up
> cause this
> > > equals to printable characters.
> > >
> > > Just my 2 of course
> > >
> > > Markus
> > >
> > > Ryan Dawson schrieb:
> > > >
> > > > Ok guys, I feel dumb asking y'all for help, but I am
> borderline going
> > > > crazy. What I am trying to do is send numbers 0 through 20
> over a
> > > > serial cable to hyperterm (running on XP).
> > > >
> > > > I have the phillips lpc2132. I provided the code below. What I
> am
> > > > not looking for a direct solution. I am looking for some hints
> for
> > > > when this code may go wrong (why it isn't sending to
> hyperterm).
> > > >
> > > > What I have done:
> > > >
> > > > 1. Setup hyperterm to 9600 baud rate, 8 bit message, no
> Parity,1
> > > > Stop bit.
> > > > 2. Flashed the program onto the board. There was no compilation
> > > > errors or warnings.
> > > >
> > > > What happens:
> > > > 1. Hyperterm shows nothing.
> > > >
> > > > What I have done to troubleshoot:
> > > >
> > > > 1. Read 2 lpc213xx manuals on UART.
> > > > 2. I have changed the values of U1LCR , U1DLL several different
> > > > times.
> > > > 3. Everytime I changed the values, I tested. Still no
> > > > communication.
> > > >
> > > > I believe that the main function is correct. The two things I
> am
> > > > worried about is the initialize function (Making sure the
> values are
> > > > right), and the putchar function (U1THR is being used
> correctly).
> > > >
> > > > Can anyone point me in the right direction please.
> > > >
> > > > ///////Start code here\\\\\\\\\\\\\\\\\\
> > > >
> > > > #include
> > > >
> > > > void Initialize(void);
> > > > int putchar(int);
> > > >
> > > > #define TEMT (1<<6)
> > > > #define LINE_FEED 0xA
> > > > #define CARRIAGE_RET 0xD
> > > >
> > > > int main()
> > > > {
> > > > int i;
> > > > Initialize();
> > > >
> > > > while(1)
> > > > {
> > > > i=0;
> > > > putchar(i);
> > > > i++;
> > > > if (i == 20) i=0;
> > > > }
> > > > }
> > > >
> > > > /*************** System Initialization ***************/
> > > > void Initialize()
> > > > {
> > > > PINSEL0 = 0x00050000;
> > > > U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop
> > > > bit */
> > > > U1DLL = 97;
> > > > U1LCR = 0x03;
> > > > }
> > > >
> > > > /**********Write character to Serial Port*************/
> > > > int putchar (int ch)
> > > > {
> > > >
> > > > if (ch == '\n') {
> > > > while (!(U1LSR & 0x20));
> > > > U1THR = CARRIAGE_RET; /* output CR */
> > > > }
> > > > while (!(U1LSR & 0x20));
> > > > return (U1THR = ch);
> > > > }
> > > >
> > > >
> > >
> > >
> >

--- In l..., "Ryan Dawson" wrote:
>
> Thanks for all of the quick replies. This is the first time I have
> posted here, and I am very impressed. Wow I guess programming late
> at night is not a good idea for me. I will fix the ASCII error and
> the terrible for loop I made.

Apart from the points made by the other posters, you really ought to
use appropriate types. A function called 'putchar' really should take
a parameter of type 'char'. If you are using a loop to generate a
stream of incrementing characters, you should use a loop counter of
type 'char'. If you had used the appropriate types, instead of just
reaching for 'int', you would have found it impossible to set '20' as
a loop terminator because '20' is illegal as a character literal.
As for the core clock issue, I am not
> sure what to do. I am unsure of what DLL does. I have read this
> from a pdf.
>
> The UART0 Divisor Latch is part of the UART0 Baud Rate Generator and
> holds the value used to divide the VPB clock (pclk) in
> order to produce the baud rate clock, which must be 16x the desired
> baud rate. The U0DLL and U0DLM registers together form
> a 16 bit divisor where U0DLL contains the lower 8 bits of the divisor
> and U0DLM contains the higher 8 bits of the divisor. A `h0000
> value is treated like a `h0001 value as division by zero is not
> allowed.The Divisor Latch Access Bit (DLAB) in U0LCR must be
> one in order to access the UART0 Divisor Latches.
>
> But I am unsure of what this means.
>

Which bit are you unsure of? The UART hardware must generate the tx
character bits at the correct rate and must also sample the incoming
rx bits at a rate that ensures that the start/data/stop bits are
interpreted correctly - this needs a baud rate clock of 16x the baud
rate. The baud rate clock is derived from the peripheral clock by a
programmable divider. The peripheral clock is used to count down an
internal divider register to zero, at which time the baud rate clock
is toggled, the internal divider register reloaded from the divisor
latch and the countdown restarts. The above text from the user manual
describes this and how to set the 16-bit divisor latch value in two
8-bit loads when the DLAB control bit in the U0LCR is set.

Rgds,
Martin

Ok now this maybe terrible and I can see some of y'all doing a face
slap because of this, but how do I find my peripheral clock rate.

Because I read further along in that .pdf and saw this chart:
Desired baud-rate U0DLM:U0DLL % error
9600 130 0.1600

And you can get this by that formula below with a 20MHz peripheral
clock rate.

20,000,000/(9600*16)= 130.*

SO that is where the 130 comes from. So I get that.

Also when I have the 130, where do I store that value into.

Do I store it in U0DLM or U0DLL.

Sorry if I am frustrating y'all.

--- In l..., Dave Such wrote:
>
> Use
>
> UoDLM + UoDLL = (pclk / (baudrate * 16))
>
>
> Ryan Dawson wrote:
> >
> > Thanks for all of the quick replies. This is the first time I have
> > posted here, and I am very impressed. Wow I guess programming late
> > at night is not a good idea for me. I will fix the ASCII error and
> > the terrible for loop I made. As for the core clock issue, I am not
> > sure what to do. I am unsure of what DLL does. I have read this
> > from a pdf.
> >
> > The UART0 Divisor Latch is part of the UART0 Baud Rate Generator and
> > holds the value used to divide the VPB clock (pclk) in
> > order to produce the baud rate clock, which must be 16x the desired
> > baud rate. The U0DLL and U0DLM registers together form
> > a 16 bit divisor where U0DLL contains the lower 8 bits of the divisor
> > and U0DLM contains the higher 8 bits of the divisor. A `h0000
> > value is treated like a `h0001 value as division by zero is not
> > allowed.The Divisor Latch Access Bit (DLAB) in U0LCR must be
> > one in order to access the UART0 Divisor Latches.
> >
> > But I am unsure of what this means.
> >
> > Again I really appreciate the help. I was at my wit's end with
> > this. Pardon the cliche.
> >
> > --- In l... ,
> > Timucin KANATLI wrote:
> > >
> > > ..and what is your core clock, Plck. U1DLL, U1LCR may be wrong, also
> > >
> > > Tim
> > >
> > >
> > > Markus Zingg wrote:
> > > >
> > > >
> > > > Ryan,
> > > >
> > > > I haven't looked at the LPC specifics of your code, but you are
> > aware of
> > > > the fact that you send binary characters 0x00 to 0x19 to
> > Hyperterm? Be
> > > > prepared for it to act quite fancy (if at all) with these
> > characters.
> > > >
> > > > For debuging purposes, you better use characters 0x40 and up
> > cause this
> > > > equals to printable characters.
> > > >
> > > > Just my 2 of course
> > > >
> > > > Markus
> > > >
> > > > Ryan Dawson schrieb:
> > > > >
> > > > > Ok guys, I feel dumb asking y'all for help, but I am
> > borderline going
> > > > > crazy. What I am trying to do is send numbers 0 through 20
> > over a
> > > > > serial cable to hyperterm (running on XP).
> > > > >
> > > > > I have the phillips lpc2132. I provided the code below. What I
> > am
> > > > > not looking for a direct solution. I am looking for some hints
> > for
> > > > > when this code may go wrong (why it isn't sending to
> > hyperterm).
> > > > >
> > > > > What I have done:
> > > > >
> > > > > 1. Setup hyperterm to 9600 baud rate, 8 bit message, no
> > Parity,1
> > > > > Stop bit.
> > > > > 2. Flashed the program onto the board. There was no compilation
> > > > > errors or warnings.
> > > > >
> > > > > What happens:
> > > > > 1. Hyperterm shows nothing.
> > > > >
> > > > > What I have done to troubleshoot:
> > > > >
> > > > > 1. Read 2 lpc213xx manuals on UART.
> > > > > 2. I have changed the values of U1LCR , U1DLL several different
> > > > > times.
> > > > > 3. Everytime I changed the values, I tested. Still no
> > > > > communication.
> > > > >
> > > > > I believe that the main function is correct. The two things I
> > am
> > > > > worried about is the initialize function (Making sure the
> > values are
> > > > > right), and the putchar function (U1THR is being used
> > correctly).
> > > > >
> > > > > Can anyone point me in the right direction please.
> > > > >
> > > > > ///////Start code here\\\\\\\\\\\\\\\\\\
> > > > >
> > > > > #include
> > > > >
> > > > > void Initialize(void);
> > > > > int putchar(int);
> > > > >
> > > > > #define TEMT (1<<6)
> > > > > #define LINE_FEED 0xA
> > > > > #define CARRIAGE_RET 0xD
> > > > >
> > > > > int main()
> > > > > {
> > > > > int i;
> > > > > Initialize();
> > > > >
> > > > > while(1)
> > > > > {
> > > > > i=0;
> > > > > putchar(i);
> > > > > i++;
> > > > > if (i == 20) i=0;
> > > > > }
> > > > > }
> > > > >
> > > > > /*************** System Initialization ***************/
> > > > > void Initialize()
> > > > > {
> > > > > PINSEL0 = 0x00050000;
> > > > > U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop
> > > > > bit */
> > > > > U1DLL = 97;
> > > > > U1LCR = 0x03;
> > > > > }
> > > > >
> > > > > /**********Write character to Serial Port*************/
> > > > > int putchar (int ch)
> > > > > {
> > > > >
> > > > > if (ch == '\n') {
> > > > > while (!(U1LSR & 0x20));
> > > > > U1THR = CARRIAGE_RET; /* output CR */
> > > > > }
> > > > > while (!(U1LSR & 0x20));
> > > > > return (U1THR = ch);
> > > > > }
> > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>
>
>
>

--- In l..., "Ryan Dawson" wrote:
>
> Ok now this maybe terrible and I can see some of y'all doing a face
> slap because of this, but how do I find my peripheral clock rate.

I'm afraid that the peripheral clock rate is generated from the main
processor clock by yet another programmable divider. This is usually
set up in the startup code by yet another load of a latch register.
Some development environments provide #defines or macros to supply the
processor and peripheral clock rate values to the 'main' application
software.

>
> SO that is where the 130 comes from. So I get that.
>
> Also when I have the 130, where do I store that value into.
>
> Do I store it in U0DLM or U0DLL.
>

To cut a long post short, if it's less than 255 shove it in DLL and
set DLM to 0

> Sorry if I am frustrating y'all.

A bit, but not as badly as some You might also search this group
for similar posts. This UART baud rate issue has come up here many
times before. There are plenty posts and links to calculators for the
values. Just googling for 'U0DLL' generated useful info in the first
link.
Rgds,
Martin