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.

CCS/MSP430FR5969: Need help with code to transmit byte of data using Launchpad

Part Number: MSP430FR5969

Tool/software: Code Composer Studio

Hi,

my customer needs help debugging his snippet of code to successfully transmit a byte of data.

Please and thank you!

--------------------------------------------------------------------------------------------------------------------------------

#include <msp430.h>

/**
* main.c
*/
volatile char received_ch = 0;
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
P1OUT |= BIT3; //Declaring SS Pin
P1DIR |= BIT3;
P1SEL1 = BIT6; //Enabling MOSI output P1.6 UCB0SIMO
P2SEL1 = BIT2; //Enabling CLK output P2.2 UCB0CLK

UCB0CTL1 = UCSWRST;
UCB0CTL0 |= UCMSB + UCMST + UCMODE_2 + UCSYNC;
UCB0CTL0 |= UCSSEL_2;// control register sets up SPI parameters for SPI mode etc.

UCB0BR0 |= 0x02; // /2
UCB0BR1 = 0;
//UCB0MCTL = 0; // No modulation??
UCB0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**

P1OUT &= (~BIT3); //Select Device

while (!(IFG2 & UCB0TXIFG)); // USCI_B0 TX buffer ready?
UCB0TXBUF = 0xA1; // Send 0xA1 over SPI to PLL
while (!(IFG2 & UCB0RXIFG)); // USCI_B0 RX Received?
received_ch = UCB0RXBUF; // Store received data

P1OUT |= (BIT3); // Unselect PLL


return 0;
}

--------------------------------------------------------------------------------------------------------------------------

Thanks,
Kevin

  • Hi Kevin,

    It looks like your customer is still learning how to set up and use the SPI peripheral on the MSP430 device. Please point them in the direction of the SPI examples in the TI Resource Explorer ( dev.ti.com/.../ )

    There are 4 different SPI examples which span the use cases of master, slave, 3-wire, and 4-wire SPI. The example code should help point them in the right direction.

    For further information on the SPI peripheral itself and the registers associated with it, please point them to the SPI chapter of the device family user's guide ( www.ti.com/.../slau367o.pdf )

    Best regards,

    Matt

**Attention** This is a public forum