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.
Hello
I would like to run the MSP430F47197 as a SPI slave in mode 0, 4 wire with the USCI_B0. but I cna't get it get it to work.
I am using the Total Phase Aardvark I2C/SPI Embedded System Interface as the host for the Master SPI and I wanted to loopback the Rx to Tx buffer. Using the Ti Code Composer Studio v4, I can see that the data gets to the UCB0TXBUF but P3.2/UCB0SOMI does not have the correct data.
Could someone tell me what is missing in the configuration of this device?
Thanks
Henry
Here is the code that is similar to the sample code msp430430x471x7_uscia0_spi_10.c :
--------------------------
void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
// FLL_CTL0 |= XCAP14PF; // Configure load caps
// Wait for xtal to stabilize
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0x47FF; i > 0; i--); // Time for flag to set
}
while ((IFG1 & OFIFG)); // OSCFault flag still set?
for(i=2100;i>0;i--); // Now with stable ACLK, wait for
// DCO to stabilize.
while(!(P3IN&BIT3)); // If clock sig from mstr stays low,
// it is not yet in SPI mode
UCB0CTL1 = UCSWRST; // **Put state machine in reset**
P3SEL |= BIT2+BIT1; // P3.1(USCI_BO_SIMO),3.2(USCI_BO_SOMI),3.3(USCI_BO_SCLK) option select
P3SEL |= BIT0; //CS
P3SEL |=BIT3; // for CLK
UCB0CTL0 |= UCSYNC|UCCKPH|UCMSB|UCMODE_2; //4-pin, 8-bit SPI slave, MSB first
UCB0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCB0RXIE;
_BIS_SR(LPM4_bits + GIE); // Enter LPM4, enable interrupts
}
// Echo character
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCIB0RX_ISR (void)// we are using the USCI_B0 for the SPI
{
if (IFG2 & UCB0RXIFG)
{
while ((IFG2 & UCB0TXIFG)==0); // USCI_B0 TX buffer ready?
UCB0TXBUF = UCB0RXBUF;
}
}
If you're master, only master, and the only master on SPI bus (which is the usual case), then you'll need to use 3wire mode. The 4th wire, STE, is for controlling the port pins in case that you are addressed as slave from a different master. Or a different master wants you to shut up. It is sort of your own CS input pin.
It has nothing to do with the requires CS signal for selecting the slave. Since SPI is a bus and there can be many slaves and every slave requires its own CS signal, the USCI doesn't handle the slave CS at all. It is up to you to do so - with plain GPIO.
You can use P3.0 for CS, btu you do not have to select it with P3SEL. You rather have to manually program it through P3DIR and P3OUT.
**Attention** This is a public forum