EmbeddedRelated.com
Forums

Att: NXP_Apps EngineersLPC2468 UART1 Auto Baud Rate with Fractional Divider

Started by winbond2 January 28, 2009
With Asia closed for Chinese new year.. I have posted the question to
this forum to see if other NXP App's engineers or experienced
engineers can offer there suggestions on an Auto baud rate detect problem.

We have a LPC2468 running with a Xtal to suit USB operation, hence we
need to use the fractional baud rate generator to meet the minimum
<2% tolerance for UART data.

We would like to use the Auto Baud rate detector hardware in the
LPC2468 as our application is replacing a modem that had "AT' auto
baud rate detection.

The LPC2468 says that fractional divider can be used with Auto baud
rate detect.

When we run Auto baud rate detect the computed U1DLM are *U1DLL are
inaccurate - where the difference between the computed and the actual
is the values in the Fractional Baud rate registers (when the error is
calculated back to register values0.

Questions
Q1 Does anyone have the auto baud rate working with fractional
divider being used?

Q2 are you able to share your working example(s)

Q3 do you have any suggestions to remedy this error in the auto baud
rate detection.

The User Manual clearly states Auto baud rate detection can be used
with the fractional divider.

Thanks in advance
Joe

An Engineer's Guide to the LPC2100 Series

-- In l..., "winbond2" wrote:

>>Questions
>>Q1 Does anyone have the auto baud rate working with fractional
>>divider being used?

>>Q2 are you able to share your working example(s)

>>Q3 do you have any suggestions to remedy this error in the auto baud
>>rate detection.

>>The User Manual clearly states Auto baud rate detection can be used
>>with the fractional divider.

>>Thanks in advance
>>Joe
--- End message ---

Has anybody else used Auto baud rate detect?

It doesn't sound like it.

If you wanted to emulate a Hayes modem... when should you use auto
baud rate detect and when should you not? How does a Hayes modem turn
the detect off/on?....eg is it turn on a at POR, on the or else?

Joe
--- In l..., "winbond2" wrote:
>
> -- In l..., "winbond2" wrote:
>
> >>Questions
> >>Q1 Does anyone have the auto baud rate working with fractional
> >>divider being used?
>
Yes, been used for LPC2148 without problems.
> >>Q2 are you able to share your working example(s)
>
Yes, found somewhere from internet long time ago.

static
void UartCalcDivider(U32 Freq, U32 Baud,
pU32 pDiv, pU32 pAddDiv, pU32 pMul)
{
U32 divisor = (Freq / 16) / Baud;
U32 mulVal = 1;
U32 divAddVal = 0;

U32 baudRateError = ((Freq / 16) /divisor) - Baud;
for (U32 mv = 0; ++mv < 16;) {
for (U32 dav = 0; ++dav < 16;) {
U32 prescaledClock = ((Freq / 16) * mv) / (mv + dav);
U32 newDivisor = prescaledClock / Baud;
if (newDivisor == 0)
continue;
U32 newBaudRateError = (prescaledClock / newDivisor) - Baud;
if (baudRateError > newBaudRateError) {
divisor = newDivisor;
mulVal = mv;
divAddVal = dav;
baudRateError =newBaudRateError;
}
}
}
*pDiv = divisor;
*pMul = mulVal;
*pAddDiv = divAddVal;
}

Usage:

UartCalcDivider(PCLK,dwBaudRate,&Div,&AddDiv,&Mul);

U1DLL = Div & 0xFF;
U1DLM = (Div >> 8) & 0xFF;
U1FDR = AddDiv + (Mul << 4);
> >>Q3 do you have any suggestions to remedy this error in the auto baud
> >>rate detection.
>
> >>The User Manual clearly states Auto baud rate detection can be used
> >>with the fractional divider.
>
> >>Thanks in advance
> >>Joe
> --- End message ---
>
> Has anybody else used Auto baud rate detect?
>
> It doesn't sound like it.
>
> If you wanted to emulate a Hayes modem... when should you use auto
> baud rate detect and when should you not? How does a Hayes modem turn
> the detect off/on?....eg is it turn on a at POR, on the or else?
>
> Joe
>

It was with some anticipation I read this posting as I've been having
problems big problems with auto-bauding too!
Unfortunately, I believe it is merely an example of the use of the
fractional prescaler, but I can't see anything in it relating to
auto-bauding, which uses the ACR register, and would not have a
parameter like "dwBaudRate". Nice search algorithm though.

Cheers,
Bruce
-----Original Message-----
From: l... [mailto:l...] On Behalf
Of alimhape
Sent: Tuesday, 3 February 2009 6:31 AM
To: l...
Subject: [lpc2000] Re: Att: NXP_Apps EngineersLPC2468 UART1 Auto Baud
Rate with Fractional Divider

--- In l..., "winbond2" wrote:
>
> -- In l..., "winbond2" wrote:
>
> >>Questions
> >>Q1 Does anyone have the auto baud rate working with fractional
> >>divider being used?
>
Yes, been used for LPC2148 without problems.
> >>Q2 are you able to share your working example(s)
>
Yes, found somewhere from internet long time ago.

static
void UartCalcDivider(U32 Freq, U32 Baud,
pU32 pDiv, pU32 pAddDiv, pU32 pMul)
{
U32 divisor = (Freq / 16) / Baud;
U32 mulVal = 1;
U32 divAddVal = 0;

U32 baudRateError = ((Freq / 16) /divisor) - Baud;
for (U32 mv = 0; ++mv < 16;) {
for (U32 dav = 0; ++dav < 16;) {
U32 prescaledClock = ((Freq / 16) * mv) / (mv + dav);
U32 newDivisor = prescaledClock / Baud;
if (newDivisor == 0)
continue;
U32 newBaudRateError = (prescaledClock / newDivisor) - Baud;
if (baudRateError > newBaudRateError) {
divisor = newDivisor;
mulVal = mv;
divAddVal = dav;
baudRateError =newBaudRateError;
}
}
}
*pDiv = divisor;
*pMul = mulVal;
*pAddDiv = divAddVal;
}

Usage:

UartCalcDivider(PCLK,dwBaudRate,&Div,&AddDiv,&Mul);

U1DLL = Div & 0xFF;
U1DLM = (Div >> 8) & 0xFF;
U1FDR = AddDiv + (Mul << 4);
> >>Q3 do you have any suggestions to remedy this error in the auto baud
> >>rate detection.
>
> >>The User Manual clearly states Auto baud rate detection can be used
> >>with the fractional divider.
>
> >>Thanks in advance
> >>Joe
> --- End message ---
>
> Has anybody else used Auto baud rate detect?
>
> It doesn't sound like it.
>
> If you wanted to emulate a Hayes modem... when should you use auto
> baud rate detect and when should you not? How does a Hayes modem turn
> the detect off/on?....eg is it turn on a at POR, on the or
else?
>
> Joe
>