Other Parts Discussed in Thread: MSP430F47197
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;
}
}