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.

MSP430 IrDA baud rate

Hi,

I have some doubts regarding the Baud Rate calculation for MSP430 IrDA,
I am using the oversampling mode with 8MHz clock and baud rate 115200bps

I am referring to the below user guide's
http://focus. ti.com/lit/ ug/slau144e/ slau144e. pdf

formula for Oversampling Baud Rate:(page 476)
UCBRFx = round( ( (N/16) − INT(N/16) ) * 16 )

Using the above formula,I am getting the values as
UCBRSx=4 and UCBRFx=5 (For 8MHz clock and speed 15200bps)

But according to the "Table 15−5.Commonly Used Baud Rates, Settings, and Errors, UCOS16 = 1"(page 482)

the values are UCBRSx=5 and UCBRFx=3 (for 8MHz clock and speed 15200bps),
and aslo using these values I am getting error in the commumication whereas the
one which I calculated from the formula does well.

Does anybody know which is the correct one, and the best way to
to calculate UCBRSx and UCBRFx values.

In the above calcuation I used the formula "UCBRSx = round( ( N − INT(N) ) * 8 )"
to calculate UCBRSx which is described in "Low-Frequency Baud Rate Mode Setting" section.
Is this a right formula to calculate UCBRSx in oversampling mode?

Thankyou in advance

  • Chakra,

    [Edit:  Assume you're talking MSP430-x2xx based on the family users guide you cite.]

    I have found the formulas to be correct, though the whole process can be hard to follow.  There are some inconsistencies in your post.  The table and page number you cite are for UCOS16=0.  If you are using UCOS16=1, then use table 15-5 on page 484.

    I made a spreadsheet to do the calculations when UCOS16=0, and the values for 8MHz, 115,2K baud agree with the table:  UCBRx = 69, UCBRSx = 4, UCBRFx = 0 (as it must when UCOS16=0).  The max Tx and Rx errors agree beween my spreadsheet and the table as well.

    As for UCOS16=1, I can't help you there.  It was a bit much to do in a spreadsheet at the time.  You can trust the table, and double check that you have coded the correct parameters, or go with UCOS16=0.

    Hope this helps.

    Mike

  •  

    Hi Mike,

    Thankyou,

    Perhaps a silly question,
    when using the table 15-5(8MHz,115200bps),
    is it right if I set the concerned register values as below?

    UCA0BR0 = 4;                              //for baud rate of 115200bps
    UCA0BR1 = 0;
    UCA0MCTL = UCBRF_3 + UCBRS_5 + UCOS16;    // Set 1st stage modulator to 5,second mod stg  to 3
                                                                                                // 16-times oversampling mode

    Regards.

  • Yep.  Looks good to me.

    Mike

  • Mike said:

    Chakra,

    ... As for UCOS16=1, ... You can trust the table, ...

    Really? I think UCOS16=1, UCBRx = 4, UCBRFx=5, and UCBSx=1 gives smaller errors (as compared with UCBSx=3 accprdomg to the table).

    Could you varify this?

  • O.C.Y.

    As I said earlier, I haven't done a spreadsheet for UCOS16=1, so I can't verify any of the numbers.  I spoke perhaps too loosely in saying you can trust the table.  Perhaps it would be better to say "you can choose to trust the table for UCOS16=1, as the table for UCSOs16=0 seems fairly trustworthy".  At any rate, if I were using UCOS16=1, I would do the calculations.  "Trust but verify." 

    That said, as I have worked with UCOS16=0, I find some cases where it can be a toss-up on choosing a value for UCBRSx.  Sometimes you may be willing to trade a low Rx error for a high one to get a better Tx error.  So maybe that's what you are seeing with the values you cite. 

    Mike

  • Hey all,

    I'm using MSP430FX2122, Right now I'm working with the uart module my desire baud rate is 4800.

    I would like to now is it possible to have such a baud rate with this microcontroller? and Do I need Modulation or no?

    aha this is good to know also I'm using internal oscilator(DCOCLK) at 1MHz.

    Thanks

  • The DCOCLK has about +/- 2% error in frequency. Thus the baudrate you generated will only be accurate to +/- 2%. If the divider is greater than 50, modulation is optional.

  • old_cow_yellow said:

    The DCOCLK has about +/- 2% error in frequency. Thus the baudrate you generated will only be accurate to +/- 2%. If the divider is greater than 50, modulation is optional.

    Thanks for your reply,I'm done with that part.

    But I have another problem which is my Recieve bytes are not correct at all.do you have any idea about this?

     

    Regards

     

  • farhad shams said:
    But I have another problem which is my Recieve bytes are not correct at all.do you have any idea about this?

    Not sure what you are doing and what are the symptoms/problem. Much less about the cause of your problem.

    Are you using the IrDA mode? If not, are you converting the RXD/TXD to/from RS232 levels? What kind of device are you tring to communicate with? Did you try to Transmit bytes? If so, did the other side received them correctly?

    You said the Recieved bytes are not correct. Are you sure you did recieve bytes? Is it possible that the hardware did not receive anything and your software just picked up garbage form the reciever buffer?

  • Yeah you are right actually my signal levels are not RS232 levels they are on CMOS 1.8. but what I did is to solder an transistor for RX input and it will amplify the signals.But after that everything will be messed up because that transistor invert bits.

**Attention** This is a public forum