Hi,
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 PM5CTL0 &= ~LOCKLPM5; // XT1 Setup CSCTL0_H = CSKEY >> 8; // Unlock CS registers CSCTL1 = DCOFSEL_0; // Set DCO to 1MHz CSCTL1 &= ~DCORSEL; CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK; CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers CSCTL4 &= ~LFXTOFF; do { 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) #else #error Compiler not supported! #endif { 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.