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.

How to calculate the value of UCBRSx in Oversampling Baud-Rate Mode

Other Parts Discussed in Thread: MSP430F5438A

Hello everyone,

I can't figure out how to select the appropriate value for UCBRSx in oversampling baud-rate mode, so to minimize the transmission error. I was able to calculate the values for UCBRx and UCBRFx, but for more precise bit rate I need to select appropriate value (0-7) for UCBRSx as well. The problem is that I don't know how to calculate that value. I am using MSP430F5438A. Any help would be much appreciated.

  • For the F5438A (USCI not eUSCI) follow User’s Guide chapter 34.3.10.1 Low-Frequency Baud-Rate Mode Setting.
  • Thank you for reply Mr. Bosch.
    Using the formula UCBRSx = round[( N – INT(N)) × 8] I chose a standard BRCLK frequency and Baud Rate from table 34-5 so I can compare the result from my calculations with the specified value for UCBRSx from the table.
    So at given:
    BRCLK = 4000 000
    Baud Rate = 57600
    We can see the corresponding value for UCBRSx = 5 (please see table 34-5). So far so good.
    But when I use the formula UCBRSx = round[( N – INT(N)) × 8] I obtain different result:
    N = 4000000/57600, N = 69.444444444444444444444444444444
    UCBRSx = round[(69.4444 - 69 )*8] =round( 0.4444*8) = round (3.55556)
    UCBRSx = 4.
    According the table UCBRSx = 5, according my calculations UCBRSx = 4. This is what bothers me. May be my calculations are wrong?
    Thank you again for your time.
  • Do you use Oversampling?
    If not you need to use table 34-4. This gives UCBRx = 69 and UCBRSx = 4.
  • Thank you for prompt reply.
    As I stated in the title of my post - YES I do use Oversampling UCOS16 = 1. I used the table only for comparison of the results. I want to calculate the value of UCBRSx for non common BRCLK frequency (e.g. 18 000 000Hz) in oversampling mode.
  • Sorry, I was sleeping and didn’t re-read your post.

    Good catch for the wiki page!

    But now confusion becomes bigger. The calculation from the wiki page gives the same values as can be found in the table from the User’s Guide but they can’t be, in my opinion, correct.

    The wiki, under (UCOS16=1), shows “UCBRSx = round(((N/16) - INT(N/16))*16)” but uses in the example “UCBRFx = ...”, UCBRFx is in my opinion correct and is in accordance with chapter 34.3.10.2. This chapter also describes that the (now) ‘Second’ modulator can be calculated after UCBRFx is calculated.

    And I think that UCBRSx must be calculated from the remainder after calculating –the INTEGER and not ROUNDED-  UCBRFx.

    Maybe  can clarify about this.

  • Hi Leo,

    The one line in the wiki that doesn't match (the line "UCBRSx = round(((N/16) - INT(N/16))*16) -> integer rounding of fractional part of N divided by 16 times 16") I believe should say UCBRFx  = . This would make it match the formula given in the user's guide, and the values that it actually generates - seeing section 34.3.10.2 it lists the same formula with UCBRFx =.  

    Now, the wiki seems to do the detailed bit rate error calculation as well it looks like, before choosing the values (this is also what I think is done in the table). Going back to the F5xx user's guide , seeing section 34.3.10.2 the last paragraph:


    "When greater accuracy is required, the UCBRSx modulator can also be implemented with values from 0 to 7. To find the setting that gives the lowest maximum bit error rate for any given bit, a  detailed error calculation must be performed for all settings of UCBRSx from 0 to 7 with the initial UCBRFx setting, and with the UCBRFx setting incremented and decremented by one."

    I think the table and wiki calculator have done this and chosen the value with the best max bit error rate. I suspect with all of the entries in the table, you'll see that if you do the simple calculation for oversampling without the bit error, you'll see that UCBRFx you calculate is within +/-1 of the value from the simple calculation. The example used above of 4000000 and 57600 baud is tricky in this respect because it generates UCBRFx and UCBRSx values that are close together so it's harder to see what happened. Try using 8,388,608 and 115200 baud as a better example to see what happens. From the simple calculation you get:

    (8,388,608/115200)/16 = 4.551111

    UCBRx = 4

    UCBRFx = (4.551111 - 4) * 16 = 8.817777.

    I think what then happens is it takes UCBRFx = 8, UCBRFx = 9, and UCBRFx =7 and does the bit error calculation with all values of UCBRSx from 0 to 7 to  find the setting combination with the best max bit error, as described in the user's guide.  In this case it seems to choose UCBRFx = 7 for both the table and the calculator. This shows the calculator is in fact setting UCBRFx first (the calculation is right but the listed formula in the wiki has a typo), and that it's also doing the bit error calculation (or else it would have just chosen 8 for UCBRFx). Does this make sense?

    I'll try to get the typo on the wiki fixed.

    Regards,

    Katie

  • Hi Katie,

    Thanks for clarification.
    I was hoping it would be simpler to calculate UCBRSx also, but it seems not. Good this wiki page with calculator is there.
    Maybe good on the wiki page to explain UCBRSx as in the manual or that it (both) can be calculated with the presented ‘USCI UART Calculator’.

    Regards,
    Leo.

**Attention** This is a public forum