Sign in

username:

password:



Not a member?

Search msp430



Search tips

Subscribe to msp430



Ads

Discussion Groups

Discussion Groups | MSP430 | How to select the correct values for the modulation register in a MSP430F241x?

The purpose of this group is to foster exchange of information on the Texas Instruments MSP430 family of microcontrollers and related tools. Everyone welcome, all levels of familiarity/expertise.

How to select the correct values for the modulation register in a MSP430F241x? - vidalastudillo - Aug 5 10:12:28 2008

Hi guys,

I'm sorry, I haven't been able to understand how to select the correct
values for the modulation register using UART.

I'm using an 8Mhz crystal and want to use 115200 Bauds.

According to the table 15−4.Commonly Used Baud Rates, Settings, and
Errors (Of the Family Manual), I have to select 4 for the UCBRSx

I have seen the Table 15−2.BITCLK Modulation Pattern, but I don't get
the way I should select the correct UCBRS_x

For example, in the sample MSP430x261x_uscia0_uart_01.c they use hte
following:

UCA0MCTL = UCBRS2 + UCBRS0; // Modulation UCBRSx = 5

How come Mr. B. Nisarga selected the UCBRS2 plus the UCBRS0 to get
Five according the table?

I appreciate your kind help!

Best regards,

Mauricio
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )


Re: How to select the correct values for the modulation register in a MSP430F241 - old_cow_yellow - Aug 5 10:52:57 2008

The example you found was using 1MHz and you use 8MHz.

--- In m...@yahoogroups.com, "vidalastudillo"
wrote:
>
> Hi guys,
>
> I'm sorry, I haven't been able to understand how to select the correct
> values for the modulation register using UART.
>
> I'm using an 8Mhz crystal and want to use 115200 Bauds.
>
> According to the table 15−4.Commonly Used Baud Rates,
Settings, and
> Errors (Of the Family Manual), I have to select 4 for the UCBRSx
>
> I have seen the Table 15−2.BITCLK Modulation Pattern, but I
don't get
> the way I should select the correct UCBRS_x
>
> For example, in the sample MSP430x261x_uscia0_uart_01.c they use hte
> following:
>
> UCA0MCTL = UCBRS2 + UCBRS0; // Modulation UCBRSx = 5
>
> How come Mr. B. Nisarga selected the UCBRS2 plus the UCBRS0 to get
> Five according the table?
>
> I appreciate your kind help!
>
> Best regards,
>
> Mauricio
>

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: How to select the correct values for the modulation register in a MSP430F241 - vidalastudillo - Aug 5 11:36:55 2008

Thank you for your prompt response old_cow_yellow ...

Actually I'm aware that in the example they use a 1 Mhz clock. Let me
make clear my problem: I don't understand how to select the values for
any clock. In the example, for 1Mhz, I don't see how they choose the
values to get 5 (which is the value to be used for that speed), and of
course, I don't see how to select 4 for my case, running a 8Mhz Crystal.
Thank you!

--- In m...@yahoogroups.com, "old_cow_yellow"
wrote:
>
> The example you found was using 1MHz and you use 8MHz.
>
> --- In m...@yahoogroups.com, "vidalastudillo"
> wrote:
> >
> > Hi guys,
> >
> > I'm sorry, I haven't been able to understand how to select the correct
> > values for the modulation register using UART.
> >
> > I'm using an 8Mhz crystal and want to use 115200 Bauds.
> >
> > According to the table 15−4.Commonly Used Baud Rates,
> Settings, and
> > Errors (Of the Family Manual), I have to select 4 for the UCBRSx
> >
> > I have seen the Table 15−2.BITCLK Modulation Pattern, but I
> don't get
> > the way I should select the correct UCBRS_x
> >
> > For example, in the sample MSP430x261x_uscia0_uart_01.c they use hte
> > following:
> >
> > UCA0MCTL = UCBRS2 + UCBRS0; // Modulation UCBRSx = 5
> >
> > How come Mr. B. Nisarga selected the UCBRS2 plus the UCBRS0 to get
> > Five according the table?
> >
> > I appreciate your kind help!
> >
> > Best regards,
> >
> > Mauricio
>
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Re: How to select the correct values for the modulation register in a MSP430F241 - Bill Knight - Aug 6 9:05:46 2008

TI has an application note explaining the process though I do not recall
its name/number. I also published USART.zip to the files section of
this group a couple of years ago which has macros in USART.h for
calculating the setting. You may wish to have a look.

Regards
-Bill Knight
R O SoftWare
vidalastudillo wrote:
> Thank you for your prompt response old_cow_yellow ...
>
> Actually I'm aware that in the example they use a 1 Mhz clock. Let me
> make clear my problem: I don't understand how to select the values for
> any clock. In the example, for 1Mhz, I don't see how they choose the
> values to get 5 (which is the value to be used for that speed), and of
> course, I don't see how to select 4 for my case, running a 8Mhz Crystal.
> Thank you!
>
> --- In m...@yahoogroups.com, "old_cow_yellow"
> wrote:
>> The example you found was using 1MHz and you use 8MHz.
>>
>> --- In m...@yahoogroups.com, "vidalastudillo"
>> wrote:
>>> Hi guys,
>>>
>>> I'm sorry, I haven't been able to understand how to select the correct
>>> values for the modulation register using UART.
>>>
>>> I'm using an 8Mhz crystal and want to use 115200 Bauds.
>>>
>>> According to the table 15−4.Commonly Used Baud Rates,
>> Settings, and
>>> Errors (Of the Family Manual), I have to select 4 for the UCBRSx
>>>
>>> I have seen the Table 15−2.BITCLK Modulation Pattern, but I
>> don't get
>>> the way I should select the correct UCBRS_x
>>>
>>> For example, in the sample MSP430x261x_uscia0_uart_01.c they use hte
>>> following:
>>>
>>> UCA0MCTL = UCBRS2 + UCBRS0; // Modulation UCBRSx = 5
>>>
>>> How come Mr. B. Nisarga selected the UCBRS2 plus the UCBRS0 to get
>>> Five according the table?
>>>
>>> I appreciate your kind help!
>>>
>>> Best regards,
>>>
>>> Mauricio

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: How to select the correct values for the modulation register in a MSP430F241 - old_cow_yellow - Aug 6 13:10:54 2008

TI did explain the BAUD Modulator. There are many pages in the Users
Guide devoted to this topic. And there are Application Notes and Code
Examples too. Thus it is probable futile for me to try to explain it
again.

Read the Users Guide more carefully. And if you are using F1xx (F2xx
is different), Bill Knight's header file helps too.

Having said that, I will try to explain anyway. (Including the
difference between F1xx and F2xx.)

If the clock frequency is an integer multiple of the BAUD, you can
just set that integer as the Divider and you do not need the Modulator
(set it to 0). The BAUD will be exactly right. For this reason, one
may use 7.3728MHz instead of 8MHz crystals. (7.3828MHz is one of the
common crystal frequencies for this reason.)

If the ratio of clock frequency vs. BAUD is not an integer but very
close to an integer or the integer part is big enough, you may not
need the Modulator either. Set the Divider to the rounded (up or down)
integer of the ratio and set the Modulator to 0. The BAUD will be
slightly off, but may be acceptable. For example, if the ratio is
99.8, set the Divider to 100 and Modulator to 0. The BAUD will be off
by (99.8-100)/99.8 =3D 0.2%

If the integer part of the ratio is small and fractional part is big,
doing it the above way may be unacceptable. For example, if the ration
is 20.4 and you set the Divider to 20, the BAUD will be off by
(20.4-20)/20.4=3D2%. It is acceptable to have the bit time off by 2%.
But this error is accumulative. The accumulated error of next bit will
be 2%+2%=3D4%, next 6%, next 8%, next 10%, next 12%, next 14%, etc.=20
This accumulated error is not acceptable

In the above example, if you divide the clock by 21 instead of 20, the
bit time will be -3% off instead of 2%. Thus it is possible to reduce
the accumulated error by selectively use divide by 20 or 21.

First bit use /20, 2% off
Next bit use /21, -3% off, accumulated -1%
Next bit use /20, 2% off, accumulated 1%
Next bit use /21, -3% off, accumulated -2%
=85 etc.

The Modulator provides a mechanism to do the above. But the USART in
F1xx and the USCI are slightly different.

In the F1xx USART, there is an 8-bit register to control modulation
and you can set it to any modulation pattern you like. Thus there are
256 possible patterns. But only a few of these 256 patterns are usable.

In the F2xx USCI, there are two modes for BAUD generation. One is very
similar to the F1xx USART. But instead of an 8-bit register for 256
pattern, there are only 3 bits to choose one of 8 different usable
modulation patterns. You only need to pick one out of the 8. You do
not need to figure out the pattern anymore.=20=20

The other mode of BAUD in F2xx USCI has a divide by 16 pre-scalar. The
modulation method is a littler different form the F1xx USART. In this
mode, you have 4 bit to choose one of 16 modulation patterns.

--- In m...@yahoogroups.com, Bill Knight wrote:
>
> TI has an application note explaining the process though I do
> not recall its name/number. I also published USART.zip to
> the files section of this group a couple of years ago which
> has macros in USART.h for calculating the setting. You may
> wish to have a look.
>=20
> Regards
> -Bill Knight
> R O SoftWare
>=20

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Re: How to select the correct values for the modulation register in a MSP430F241 - John Luciani - Aug 6 13:21:21 2008

On Tue, Aug 5, 2008 at 11:36 AM, vidalastudillo wrote:

> Thank you for your prompt response old_cow_yellow ...
>
> Actually I'm aware that in the example they use a 1 Mhz clock. Let me
> make clear my problem: I don't understand how to select the values for
> any clock. In the example, for 1Mhz, I don't see how they choose the
> values to get 5 (which is the value to be used for that speed), and of
> course, I don't see how to select 4 for my case, running a 8Mhz Crystal.
>

I wrote a Perl script for calculating the values for the baud rate register.
The script and
some documentation is at ---

http://www.luciani.org/uC/uC-index.html

(* jcl *)

--
http://www.luciani.org
[Non-text portions of this message have been removed]
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )