This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Baud rate calculation

Other Parts Discussed in Thread: MAX3232, MSP430F2274, TUSB3410, MSP430F1232

I'm using the target board from the ez430-rf2500 and connected it with MAX3232 to a serial port.

It is running at 16 MHz and I'm using the table 15-4 in slau144e to set my UCA0BR0, UCA0BR1 and UCA0MCTL registers. I've tried 9.6k, 19.2k, 38.4k, 115.2k baud rate and they all worked perfectly. The problem came in when I was trying to move to230.4k baud rate. I calculated the following settings since they are not in the table. 

 

  UCA0BR0 = 0x45;                           

  UCA0BR1 = 0x0;

  UCA0MCTL = 0xAA;

The only thing I got through the port is jibberish. Is my setting correct? I saw that is possible to set 230.4k baud rate using oversampling mode in table 15-5, but is there any way to do it without using that mode? 

Thanks in advance. 

 

  • I think your setting:

      UCA0MCTL = 0xAA;

    is incorrect. It should have been 0x08.

  • I have just tried it, but no dice.

     

    This is how i did the com port

      P3SEL |= 0x30;                                  // P3.4,5 = USCI_A0 TXD/RXD

      UCA0CTL1 = UCSSEL_2;               // SMCLK

    //  UCA0BR0 = 0x82;                           // 9600 from 16Mhz

    //  UCA0BR1 = 0x6;

    //  UCA0MCTL = UCBRS_2;    

    //

    //  UCA0BR0 = 0x8A;                           // 115200 from 16Mhz

    //  UCA0BR1 = 0x0;

    //  UCA0MCTL |= UCBRS_7;

    //  

      UCA0BR0 = 0x45;                            // 230400 from 16MHz

      UCA0BR1 = 0x0;

      UCA0MCTL = 0x08;

     

      UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**

      IE2 |= UCA0RXIE;                          // Enable USCI_A0 RX interrupt

      __enable_interrupt(); 

     

    And what I did was just sending a string of characters 

    TXString( "\r\nInitializing Network....", 26 );

  • Are you sure your RS232 converter chip can handle 230.4 kb/s?

    Are you sure the device you use to receive the transmission can handle 230.4 kb/s?

    If you have an oscilloscope, you could check the timing of TXD. Send the ASCII code of "U" (0x55), TXD should show 5 negative pulses of 4.34 usec each with 4.34 usec spaces in-between.

  • The MAX3232 spec said it supports up to 250kbps, and msp430F2274 should be able to output at that rate as well according to slau144e.

    I'm trying out your suggestion to look at the timing. I added '<' (should be 0011 1100?) in it so I can tell the where 'U' is when I send them repeatedly. I measured 4.4 usec on both the pulse and space between them. 

    Attached is what I'm looking at in the oscilloscope

    http://i53.tinypic.com/2u4j0p2.jpg

     

  • I cannot see the picture you got. But your observed 4.4 usec is within 1.5% of the expected 4.34 usec. This difference could mean (a) the MCTL register setting is wrong, (b) your 16 MHz SMCLK is 1.5% slow, or (c) your scope horizontal scale is 1.5% fast.

    Let us go back to calculations.

    16000000 / 230400 = 69.444...

    The USCI hardware can only divide SMCLK by integers. Thus you can only use either 69 (0x45) or 70 (ox46) as the divider. But USCI also has a "modulator" which allows it to use the next higher divider for some of the bits out of each 8 consecutive bits. In the current case, you can use 69 (0x45) as the "nominal" divide, but tell the modulator to use 70 as the divider 4 out of 8 bits. This will result an effective divider close to 69.5.

    For USCI, setting MCTL to 0x08 will generate the "modulator" pattern 10101010 (0xAA). But you should not set MCTL=0xAA;. You set MCTL=0x08; and it will modulate with 0xAA.

    Anyway, I think your problem is caused by (b) or (c). Not caused by (a).

     

     

     

  • I think you may have hit the jackpot of the problem. I tested the same settings 0x45, 0x00, 0x08 on 4 different target boards of ez430-rf2500 and just keep asking them sending 'U' to the port, and they all have slightly different timing than each other. The readout are also different among all of them. One comes out as a combination of 'J' and 'K' ; one is '<', 'p', 'x' , and the other two are jibberish symbols. 

     

    Here's the picture (http://e2e.ti.com/members/1452004/files/IMAG0125.jpg.aspx) I just realize you can upload stuff to ti a/c.

     

    Thanks for the advices, old_cow_yellow

     

     

  • Hi,

    I know ez430-RF2500, which uses MSP430F2274 with internal DCO. I also want to raise the baud rate of UART of 2274. But I doubt whether the internal DCO can support higher data rate or not.

    Anything update?

    Allan

  • Kai Liu101519 said:
    But I doubt whether the internal DCO can support higher data rate or not.

    Well, teh DCO doe ssupport any baudrate. The problem is to find the DCo setting for a specific baudrate. As the DCO has large differences in frequencies across MSPs. You'll have to calibrate it device by device.

    However, on F2274, Ti has done calibration for some frequencies and stored the optimum DCO setting for those frequencies in info memory. Those caibration values have +-2.5% accuracy on VCC=3V. Worse for other voltages. This should be good enough for RS232. But keep in mind that these up to 2.5% are added to the error calculations in the users guide baudrate tables (which assume 100% accurate clock).

    Now on EZ430-RF2500, the integrated UART connection is baudrate-limited (AFAIK 9600Bd), because it is only a software UART, implemented on some unused I/O pins of the TUSB controller. So no matter how precise your DCO is, you won't be able to use higher baudrates through this connection. OYu'll need a separate, full-feaured USB/ser adapter for more than 9600Bd.

  • Thanks for your reply. And I am sorry for repeat my questions in different thread. I though different people can give different replies, so I can find the correct one.

    If TUSB3410 uses its hardware UART to talk with MSP430F16X on ez430, then its application UART has to be a bit-bang software UART. And 8052 core is quite slow, 9600 is reasonable baud rate.

    I got it now. I have to find out to check if it works on 3V and regular room temperature for high data rates.

  • Kai Liu101519 said:
    I though different people can give different replies

    Well, if you write to a thread, it pops on top of the thread list, and everyone can read it, not just the ones who wrote in it originally (and sometimes are long gone anyway). With one thread (even a freshly started one) you'll get as much attraction as possible. Writing in more than one thread will actually have an adverse effect, as then four old threads pop on top and everyone sees the same question four times in a row. Possibly ignoring you then.

    Kai Liu101519 said:
    its application UART has to be a bit-bang software UART

    Yes, that's the case. It's nice to have it, but for higher baudrates, an independent connection must be used.

    Kai Liu101519 said:
    I got it now. I have to find out to check if it works on 3V and regular room temperature for high data rates.

    On an MSP430F1232 and F1611, I have a fallback to 4MHz DCO if the 8MHz crystal fails. The fallback is not individually calibrated, only using an average setting for all devices, but serial communication with PC still works in most cases, even with 115200Bd. (and for the few other ones, I have a more tolerant interface that accepts a wider baudrate range and translates to 115200Bd)
    With the calibrated DCO values you shouldn't have problems.

**Attention** This is a public forum