Strange Uart Problem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Strange Uart Problem

Thiago P. F. S. Lima
I'm developing a project for a Master Modbus using MSP430F149.
I'm using in this project a external crystal of 32K.

The parameter i'm using are, as follow:
/*
  Baud Rate table:
  clock: 8000000Hz
  desired baud rate: first element
  UBR00: second element
  UBR10: third element
  UMCTL0: fourth element

  http://mspgcc.sourceforge.net/baudrate.html -
  Thanks to Pedro Zorzenon Neto -- pzn at debian.org
*/
const struct sserial serial[] =
  {
    { 1200, 0x0A, 0x1A, 0x5B },
    { 2400, 0x05, 0x0D, 0x52 },
    { 4800, 0x82, 0x06, 0x5B },
    { 9600, 0x41, 0x03, 0x09 },
    { 19200, 0xA0, 0x01, 0x5B },
    { 28800, 0x15, 0x01, 0xBB },
    { 38400, 0xD0, 0x00, 0x11 },
    { 57600, 0x8A, 0x00, 0xEF },
    { 115200, 0x45, 0x00, 0xAA },
    { 0, 0, 0, 0 }
  } ;

My project is working for 115200 and 57600 kbps, with parity bit, stop
bit and number of byte changes. The same uart, uart 0, is used for
debug, in the terminal with a default and unchangeble value 57600,8N1
and is also used for modbus communication (RS232 or RS485 - external
jumper selected). Modbus is ok for 57600 and 115200 with many
equipments. I also tested for debug in the computer terminal, using
RS232 alternative, printing some sentences and it worked for all baud
rates: 1200, 2400, 4800, 9600, 19200, 28800, 38400, 57600, 115200. So,
it's not a problem of registers value.

When I want to communicate in Modbus, I switch a MUX and change RS232 to
(RS485 or RS232 - choose by external jumper) communication and get the
values for desired baud rate in the table, and the value for parity bit,
stop bit and number of bits in ctl_u0 (unsigned char, entered by user).

P2OUT |= CLP_M;
UBR00 = brate0;
UBR10 = brate1;
UMCTL0 = ctl_um0;
U0CTL = ctl_u0;


When the modbus communication is over, I load the default
settings(57600,8N1):

P2OUT &= ~CLP_M;
UBR00=0x8A;
UBR10=0x00;
UMCTL0=0xEF;
U0CTL = CHAR + SPB;
U0TCTL = SSEL1;

Why does this project only works for 57600 and 115200? I have not this
answer. If anyone, please could help me solve this problem.

Thiago P. F. S. Lima
Eletronic Engineer


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: Strange Uart Problem

Dale Cunningham
I don't see these statements in your code:

U0CTL = SWRST; // Hold USART in reset until configured
// do configuration here
U0CTL &= ~SWRST;// Initialize USART state machine

You might try including them around your baud rate and configuration
changes as well as doing bit operations on U0CTL like:
U0CTL |= CHAR + SPB;

I believe the manual says something about the UART possibly not working
if settings are altered while not in reset.

Dale

Thiago P. F. S. Lima wrote:

> I'm developing a project for a Master Modbus using MSP430F149.
> I'm using in this project a external crystal of 32K.
>
> The parameter i'm using are, as follow:
> /*
>   Baud Rate table:
>   clock: 8000000Hz
>   desired baud rate: first element
>   UBR00: second element
>   UBR10: third element
>   UMCTL0: fourth element
>
>   http://mspgcc.sourceforge.net/baudrate.html -
>   Thanks to Pedro Zorzenon Neto -- pzn at debian.org
> */
> const struct sserial serial[] =
>   {
>     { 1200, 0x0A, 0x1A, 0x5B },
>     { 2400, 0x05, 0x0D, 0x52 },
>     { 4800, 0x82, 0x06, 0x5B },
>     { 9600, 0x41, 0x03, 0x09 },
>     { 19200, 0xA0, 0x01, 0x5B },
>     { 28800, 0x15, 0x01, 0xBB },
>     { 38400, 0xD0, 0x00, 0x11 },
>     { 57600, 0x8A, 0x00, 0xEF },
>     { 115200, 0x45, 0x00, 0xAA },
>     { 0, 0, 0, 0 }
>   } ;
>
> My project is working for 115200 and 57600 kbps, with parity bit, stop
> bit and number of byte changes. The same uart, uart 0, is used for
> debug, in the terminal with a default and unchangeble value 57600,8N1
> and is also used for modbus communication (RS232 or RS485 - external
> jumper selected). Modbus is ok for 57600 and 115200 with many
> equipments. I also tested for debug in the computer terminal, using
> RS232 alternative, printing some sentences and it worked for all baud
> rates: 1200, 2400, 4800, 9600, 19200, 28800, 38400, 57600, 115200. So,
> it's not a problem of registers value.
>
> When I want to communicate in Modbus, I switch a MUX and change RS232 to
> (RS485 or RS232 - choose by external jumper) communication and get the
> values for desired baud rate in the table, and the value for parity bit,
> stop bit and number of bits in ctl_u0 (unsigned char, entered by user).
>
> P2OUT |= CLP_M;
> UBR00 = brate0;
> UBR10 = brate1;
> UMCTL0 = ctl_um0;
> U0CTL = ctl_u0;
>
>
> When the modbus communication is over, I load the default
> settings(57600,8N1):
>
> P2OUT &= ~CLP_M;
> UBR00=0x8A;
> UBR10=0x00;
> UMCTL0=0xEF;
> U0CTL = CHAR + SPB;
> U0TCTL = SSEL1;
>
> Why does this project only works for 57600 and 115200? I have not this
> answer. If anyone, please could help me solve this problem.
>
> Thiago P. F. S. Lima
> Eletronic Engineer
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> Mspgcc-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users