Everyone,
I am using a MSP430F5638 to communicate with a ADXL345 accelerometer through 4-pin SPI. I have been unable to get a signal from any of the 4 pins using an oscilloscope. I have used the following settings to initialize the SPI:
UCB1CTL1 = UCSWRST + UCSSEL_2;
UCB1CTL0 = UCCKPH + UCCKPL + UCMST + UCMODE_2;
UCB1CTL1 &= ~UCSWRST; //Enable USCI
UCB1BR0 = 3;
UCB1BR1 = 0;
UCB1IE |= UCRXIE;
After initialization, I have a while loop with the following code (interrupt is included).
while(1)
{
if(i > 2)
{
while (!(UCB1IFG&UCTXIFG)); // USCI_A0 TX buffer ready
UCB1TXBUF = 0x36;
i++;
}
}
#pragma vector=USCI_B1_VECTOR
__interrupt void USCI_B1_ISR(void)
{
temp = UCB1RXBUF;
P6DIR |= BIT1;
P6SEL &= ~BIT1;
P6OUT &= ~BIT1;
}
I have googled about SPI/STE issues, looked over this forum, reviewed sample code and read the family and chip-specific datasheets multiple times to try and figure out what I am doing wrong. My question is 1) what am I doing wrong in my code? 2) Do I need to set the STE in my code before Tx/Rx or does setting the UCMODE_2 make the software handle that automatically (Page 777 and 778 in the family manual are a bit ambiguous on how to set STE)?