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.

MSP430FR5869: Master SPI configuration

Part Number: MSP430FR5869


I am trying to use MSP430FR5869 as SPI master. I am configuring UCB0 port for MISO and MOSI data transfer. I have followed sample code given below

int main(void)
  WDTCTL = WDTPW | WDTHOLD;                 // Stop watchdog timer

  // Configure GPIO
  P1SEL1 |= BIT5;                           // Configure SPI pins
  P2SEL1 |= BIT0 | BIT1;
  PJSEL0 |= BIT4 | BIT5;                    // For XT1

  // Disable the GPIO power-on default high-impedance mode to activate
  // previously configured port settings

  // XT1 Setup
  CSCTL0_H = CSKEY >> 8;                    // Unlock CS registers
  CSCTL1 = DCOFSEL_0;                       // Set DCO to 1MHz
  CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers
    CSCTL5 &= ~LFXTOFFG;                    // Clear XT1 fault flag
    SFRIFG1 &= ~OFIFG;
  }while (SFRIFG1&OFIFG);                   // Test oscillator fault flag
  CSCTL0_H = 0;                             // Lock CS registers

  // Configure USCI_A0 for SPI operation
  UCA0CTLW0 = UCSWRST;                      // **Put state machine in reset**
  UCA0CTLW0 |= UCSYNC | UCCKPL | UCMSB;     // 3-pin, 8-bit SPI slave
                                            // Clock polarity high, MSB
  UCA0CTLW0 |= UCSSEL__SMCLK;               // ACLK
  UCA0BR0 = 0x02;                           // /2
  UCA0BR1 = 0;                              //
  UCA0MCTLW = 0;                            // No modulation
  UCA0CTLW0 &= ~UCSWRST;                    // **Initialize USCI state machine**
  UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt

  __bis_SR_register(LPM0_bits | GIE);       // Enter LPM0, enable interrupts

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
#error Compiler not supported!
  while (!(UCA0IFG&UCTXIFG));               // USCI_A0 TX buffer ready?
  UCA0TXBUF = UCA0RXBUF;                    // Echo received data

I did not include the highlight section in my code because I do not need to configure clock as I will be using default SMCLK. However when I test the program there are no output on MOSI pin. Do I have to include the clock configuration section in order for SPI master to work? Thank you.

  • Hi,

    in principle the SPI should be able to work also with other clock settings. What I see from the code you pasted in is you're enabling just the SPI RX interrupt. Only in the respective ISR you would trigger on RX SPI interrupt an SPI transmit. Thus with your code first you'd need to trigger initial RXIE, then the device would issue a transmit in the ISR.

    Best regards