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.

MSP430F5325: Trouble implementing hardware SPI using USCI_A0

Part Number: MSP430F5325
Other Parts Discussed in Thread: MSP-FET,

Hello all,

I am relatively new to MSP430 devices and have recently designed my own prototype board for the MSP430F5325. I have run some simple code on it using an MSP-FET over the SPI-Bi-WIRE debugging interface in CCS and I am now trying to output data over SPI. I have followed this tutorial on YouTube for a different MSP430 device and while it was helpful, it did not work, and after making some changes I still cannot get it working. I've read the product datasheet and searched for relevant information in the family datasheet, but am still having little luck. I think I must be missing something. 

Here is my code:

#include <msp430.h>

char packet[] = {0xF0, 0xF0, 0xF0, 0x40};
unsigned int position;

void main(void)
{
    WDTCTL = WDTPW | WDTHOLD;       // stop watchdog timer

    // -- setup A0 for SPI
    UCA0CTLW0 |=  UCSWRST;          // put A0 into SW Reset

    UCA0CTLW0 |= UCSSEL__SMCLK;     // Choose SMCLK

    UCA0BRW = 10;                  // Set prescaler to 10 to get SCLK = 400kHz

    UCA0CTLW0 |= UCSYNC;            // Put A0 into SPI mode
    UCA0CTLW0 |= UCMST;             // Put into SPI Master

    // -- configure ports
    P2DIR |= BIT7;
    P2SEL |= BIT7;                // P2.7 = SCK (01)

    P3DIR |= BIT3;
    P3SEL |= BIT3;                // P3.3 = SIMO (01)

    P3DIR &= ~BIT4;
    P3SEL |= BIT4;                // P3.4 = SOMI (01)


    UCA0CTLW0 &=  ~UCSWRST;          // Take out of SW Reset

    //-- Enable IRQs
    UCA0IE |= UCTXIE;               // enable A0 Tx IRQ
    UCA0IFG &= ~UCTXIFG;            // clear flag

    __enable_interrupt();           // enable global

    UCA0TXBUF = packet[position];   // send first byte


    while(1){}

    //return 0;
}

 // ------------------------------------------
 // -- ISR
 //void __attribute__((interrupt(USCI_A0_VECTOR)))
#pragma vector = USCI_A0_VECTOR
__interrupt void ISR_USCI_A0(void)
{
     position++;

     if (position < sizeof(packet))
     {
         UCA0TXBUF = packet[position];
     } else
     {
         UCA0IFG &= ~UCTXIFG;
     }

 }

Initially I was using PxSELy like the person in the YouTube video, however I then learned my controller only has one PxSEL register so I removed the second register set. I added the PxDIR lines to try and get some sort of output but I've also tried without them. I am measuring my signal with an ADALM2000 using it's oscilloscope setting. I've managed to see some pins going high or low depending on what I try but nothing that resembles the serial data I expect. 

All help and feedback is appreciated. Thanks!

**Attention** This is a public forum