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

Reply via email to