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.
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
**Attention** This is a public forum