Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 227523

Forum Post: MSP430 FRAM Series SPI Slave Transmit Issue

$
0
0

I am using the MSP430 FR5739 to work as a 4-pin SPI slave device.  I am following the example code as well as following the datasheet to properly initialize it.  However, while I am able to receive data from the master, I am not able to transmit data to the master.  I am currently only working with bits at a time.  Below is an example of how I am initializing and running the MSP430.

#define MOSI BIT0
#define MISO BIT1
#define SPI_SS BIT4
#define SPI_CLK BIT5


void SPI_init(void)
{ // Configure SPI Pins
    // Pin 1.5 set for Serial Clock Out (UCA0CLK)
    // Pin 1.4 set for SS (Slave Select) (UCA0STE)
    P1SEL1 |= SPI_CLK + SPI_SS;

    // Configure SPI pins P2.0 and P2.1
    // Pin 2.0 set for Data Out (UCA0SIMO)
    // Pin 2.1 set for Data In (UCA0SOMI)
    P2SEL1 |= MOSI + MISO;
    UCA0CTLW0 |= UCSWRST; // **Put state machine in reset**

    
    UCA0CTLW0 |= UCSYNC + UCCKPL + UCMSB + UCMODE1; // 4-pin, 8-bit SPI slave
    // Clock polarity high, MSB
    // w/ UCxSTE Active Low
    UCA0CTLW0 |= UCSSEL_2; // ACLK
    UCA0BR0 = 0x02; // /2
    UCA0BR1 = 0; //
    UCA0MCTLW = 0; // No modulation
    UCA0CTLW0 &= ~UCSWRST; // **Initialize USCI state machine**
    UCA0IE |= UCRXIE;// + UCTXIE; // Enable USCI_A0 RX interrupt
}
int main(void)

{

    SPI_init();

    while (1)

    {

        while ((P1IN & SPI_SS) != 0);
        while ((P1IN & SPI_CLK) != 0); // wait for clock to go down
        TXData = 0x00;
        UCA0IE |= UCTXIE; // Force
        while (UCA0IE & UCTXIE);
        while (!(UCA0IFG & UCRXIFG));

        //Do Something

    }
}

#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
    volatile unsigned int i;

    switch(__even_in_range(UCA0IV,0x04))
    {
        case 0: break; // Vector 0 - no interrupt
        case 2:
            while ((P1IN & SPI_SS) != 0);
                            LED7_HIGH;
            RXData = UCA0RXBUF;
            UCA0IFG &= ~UCRXIFG;
            __bic_SR_register_on_exit(CPUOFF);// Wake up to setup next TX
            break;
        case 4:
            while ((P1IN & SPI_SS) != 0);
            LED8_HIGH;
            UCA0TXBUF = TXData; // Transmit characters
            UCA0IE &= ~UCTXIE;
            break;

         default: break;
   }
}

And below is the signal output analyzed on a digital analyzer

Where the top red signal is the clock, the next signal is the CS (or Slave Select), the next is the MISO, and lastly, the bottom is the MOSI.  Does anybody have any suggestions?


Viewing all articles
Browse latest Browse all 227523

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>