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.

MSP430FR4133: Mapping code from MSP430G2553 to MSP430FR4133

Part Number: MSP430FR4133
Other Parts Discussed in Thread: MSP430G2553

Im trying to map code from an existing library I found so that I can drive a ws2812b LED strip. I found the library here https://github.com/mjmeli/MSP430-NeoPixel-WS2812-Library. Ive made an attempt at mapping it for my specific part but the code still does not seem to work.  There are 3 small sections that I need to change for my specific part and here are my attempts. The 3 blocks of code include the original code as well as my equivalent code. I need help with identifying a problem or some tips on how to map code from one MSP to another as I have no experience with doing so.

The first section is needed to configure the UCB0SIMO as the SPI Output

// ORIGINAL
#define OUTPUT_PIN  (0x80)  // Set to whatever UCB0SIMO is on your processor (Px.7 here)
    
P1SEL |= OUTPUT_PIN;    // configure output pin as SPI output
P1SEL2 |= OUTPUT_PIN;

//My equivalent code

P5SEL0 |= BIT2;    // configure output pin as SPI output

The second is checking the UCB interrupt flags. This is where I think the problem may be coming from? On the datasheet for my part this is in the data sheet: UCB0RXIFG, UCB0TXIFG (SPI mode) but when I use them I get an undefined error.

// Original Code

while (!(IFG2 & UCB0TXIFG))
;    // wait to transmit

// My equivalent code
while (!(SFRIFG1 & UCTXIFG))
;    // wait to transmit

And the 3rd section is initialising a 16 MHz clock

//Original Code

    if (CALBC1_16MHZ==0xFF)    // If calibration constant erased
    {
        while(1);              // do not load, trap CPU!!
    }

    // configure clock to 16 MHz
    BCSCTL1 = CALBC1_16MHZ;    // DCO = 16 MHz
    DCOCTL = CALDCO_16MHZ;
    
    
// My equivalent code

void initClockTo16MHz()
{
    // Configure one FRAM waitstate as required by the device datasheet for MCLK
    // operation beyond 8MHz _before_ configuring the clock system.
    FRCTL0 = FRCTLPW | NWAITS_1;

    __bis_SR_register(SCG0);    // disable FLL
    CSCTL3 |= SELREF__REFOCLK;  // Set REFO as FLL reference source
    CSCTL0 = 0;                 // clear DCO and MOD registers
    CSCTL1 &= ~(DCORSEL_7);     // Clear DCO frequency select bits first
    CSCTL1 |= DCORSEL_5;        // Set DCO = 16MHz
    CSCTL2 = FLLD_0 + 487;      // set to fDCOCLKDIV = (FLLN + 1)*(fFLLREFCLK/n)
                                //                   = (487 + 1)*(32.768 kHz/1)
                                //                   = 16 MHz

    __delay_cycles(3);
    __bic_SR_register(SCG0);                        // enable FLL
    while(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1));      // FLL locked

    CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK;
}

  • Hi Christopher,

    It looks like you are using #defines for the MSP430G2553, which are not the same as the #defines for the MSP430FR4133 and is why you are getting the undefined error. In your project, take a look at the msp430fr4133.h file (found under the Includes folder in your project). You will see that the TXIFG defines are different, and you can use the definitions for SPI found there. The specific flags are described in more detail in Section 23 of the FR4133 User's Guide linked here. Once you change these definitions, if you are still getting errors, let me know.

    Best,
    Amruta 

  • Hello Amruta,

    Thank you very much for taking the time to look at my problem. I've had a look at the msp430fr4133 header file but I'm struggling to find a #define for a USCI transmit interrupt flag. I have also had a look at the user guide section 23 but can't seem t figure out a feasible solution.  I have found a UCB0IFG but this doesn't seem to fix my problem. I don't have any undefined errors now but when I try to monitor the output of pin 5.2 (UCB0SIMO), there is no output coming from the pin.

  • Hi Christopher,

    Try the UCTXIFG flag; see the images below.

    Let me know if you have any further issues.

    Best,
    Amruta 

**Attention** This is a public forum