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.

MSP430FR2155: SPI Communication and SPI clock frequency setting

Part Number: MSP430FR2155
Other Parts Discussed in Thread: MSP430G2553,

Hello,

I am trying to implement SPI communication using MSP430FR2155 microcontroller by setting the SPI frequency to 8MHz. But I am not able implement it. I have found some SPI code related to MSP430G2553 microcontroller and that code working fine on MSP430G2XL.

But I want implement that on MSP430FR2155. I have tried the same code by changing the SPI pin declarations and some registers but its now working.

Can anyone tell how different MSP430G2553 AND MSP430FR2155 register coding. 

This is the working code of MSP430G2553. Kindly tell me what changes need to be done for working on MSP430FR2155.

#include <msp430.h>
unsigned char MST_Data,;
int main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1OUT = 0x00; // P1 setup for LED & reset output
P1DIR |= BIT0 + BIT5; //
P1SEL = BIT1 + BIT2 + BIT4;
P1SEL2 = BIT1 + BIT2 + BIT4;
UCA0CTL0 |= UCCKPL + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI master
UCA0CTL1 |= UCSSEL_2;
UCA0BR0 |= 0x02; // /2
UCA0BR1 = 0; //
UCA0MCTL = 0; // No modulation
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
P1OUT &= ~BIT5; // Now with SPI signals initialized,
P1OUT |= BIT5; // reset slave
__delay_cycles(75); // Wait for slave to initialize
MST_Data = 0xAA; // Initialize data values
while(1)
{
UCA0TXBUF = MST_Data; // Transmit first character
__delay_cycles(50000);

}
}

  • Hi Balaji,

    Is the problem you aren't seeing anything toggle on the IO pins? or is it running at the wrong frequency?

  • Hi Dennis, Thank you for the response.

    No I didn't see anything on the GPIO pin(SPI clock pin). I have checked that using Oscilloscope. But I can't see anything. Frequency also it is not showing.

    But On SPI MOSI pin I can see the data (0xAA) as per the program.

    Only issue I am facing is with respect to frequency.

    Can you tell me what might be the issue?

    And if set SMCLK as SPI clock frequency. How much will be SPI click frequency?

  • Hi Balaji,

    After checking the FR2155 datasheet, I see the SPI you are trying to use is on P1.1(UCB0CLK), P1.2 (UCB0SIMO) and P1.3(UCB0SOMI) so the registers you are writing to are different.  

    To configure the clock system to something other than the 1MHz default, there is an example showing how to do this in the TI resource explorer (TIREX).

    Try the attached modified code example.

    int main(void)
    {
        volatile unsigned int i;
        
        WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
        // Set MCLK = 16MHz
        // 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
        
        P1OUT = 0x00; // P1 setup for LED & reset output
        P1DIR |= BIT0 + BIT5; //
        P1SEL0 = BIT1 + BIT2 + BIT3;
        
        UCB0CTLW0 &= ~UCSWRST;
        UCB0CTLW0 |= UCCKPL | UCMSB | UCMST | UCSYNC | UCSSEL__SMCLK; // 3-pin, 8-bit SPI master
        UCB0CTLW1 |= UCSSEL_2;
        UCB0BRW = 0x02;     // Assumes SMCLK = MCLK = 16MHz so divide by 2
        UCB0CTLW0 &= ~UCSWRST; // **Initialize USCI state machine**
        
        P1OUT &= ~BIT5; // Now with SPI signals initialized,
        P1OUT |= BIT5; // reset slave
        __delay_cycles(75); // Wait for slave to initialize
        MST_Data = 0xAA; // Initialize data values
        
        while(1)
        {
            UCB0TXBUF = MST_Data; // Transmit first character
            __delay_cycles(50000);
        }
    }

  • Hi Balaji,

    It's been a while since we have heard from you, so I'm going to assume you were able to move forward with your project.
    I will mark this posting as RESOLVED, but if this isn’t the case, please click the "This did NOT resolve my issue" button and reply to this thread with more information.
    If this thread is locked, please click the "Ask a related question" button, and in the new thread describe the current status of your issue and any additional details you may have to assist us in helping to solve your issues.

**Attention** This is a public forum