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.

MSP430FR2355: register won't update with value???

Part Number: MSP430FR2355
#include <msp430.h>
#include "stdlib.h"
#include "string.h"
#include "stdio.h"

    float f, b;
    int d;
    struct confComm
    {
        char clkFrq[9];
        char baudRate[6];
    };

void main()
{
    struct confComm const s = {"16000000", "115200"};
    f = (float)atol(s.clkFrq);
    b = (float)atol(s.baudRate);
    d = (int)(((f/b/16) - (int)(f/b/16)) * 16);
    UCA0CTLW0 = UCSWRST;
    UCA0BRW = (int)(f/b/16);
    UCA0MCTLW = d;
    UCA0CTLW0 &= ~UCSWRST;
}

Can someone please explain to me why UCA0MCTLW will NOT update to the value d?  if I look at the expression for d it is correct.

Thanks

  • Steve Wenner said:
    Can someone please explain to me why UCA0MCTLW will NOT update to the value d? 

    The UCAxMCTLW Register has some reserved bits which always read as zero:

    The code needs to populate the individual UCBRSx, UCBRFx and UCOS16 fields in the UCA0MCTLW register.

  • So much awful in one place.

    Floating point and all the library code that drags in is not required. Simple integers are all that are required. But if the values are known at compile time, there is no need even for that. For table values like this, just look them up in the user guide.

**Attention** This is a public forum