Tool/software: Code Composer Studio
Hi all,
I am currently working on an SPI read function to pull data from an accelerometer (AIS328DQ) and am not able to see any traffic on the MISO line. I am able to see the correct traffic on the MOSI line where I am attempting to read from a specific address, but the MISO line is 0xFF when the correct value I should see according to the datasheet is 0x32. I have pasted my code below and also the screenshot from my logic analyzer
void PortBInit()
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
//GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_5);
//GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_PIN_1);
GPIOPinConfigure(GPIO_PB4_SSI2CLK);
GPIOPinConfigure(GPIO_PB5_SSI2FSS);
GPIOPinConfigure(GPIO_PB7_SSI2TX);
GPIOPinConfigure(GPIO_PB6_SSI2RX);
GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_7 | GPIO_PIN_6 | GPIO_PIN_5 |
GPIO_PIN_4);
}
void SPIInit()
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_SSI2))
{
}
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//moto_mode_3 -> CPOL = 1, CPHA = 1
SSIDisable(SSI2_BASE);
SSIConfigSetExpClk(SSI2_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_3, SSI_MODE_MASTER, 1000000, 8);
SSIEnable(SSI2_BASE);
}
void AIS328DQ::read(uint8_t numBytes, uint8_t registerAddress)
{
uint8_t bytesProcessed = 0;
//first byte send contains address we want to read from
//second byte sent contains 0's
uint8_t addReadBit = 0x80;
TxDataArray[0] = (registerAddress | addReadBit);
TxDataArray[1] = 0x00;
// Read any residual data from the SSI port. This makes sure the receive
// FIFOs are empty, so we don't read any unwanted junk.
// The "non-blocking" function checks if there is any data in the receive
// FIFO and does not "hang" if there isn't.
while(SSIDataGetNonBlocking(SSI2_BASE, &RxDataArray[0]));
//SSIDataGet(SSI2_BASE, &RxDataArray[0]);
while (bytesProcessed < numBytes)
{
//put data into the Tx FIFO
while (SSIBusy(SSI2_BASE));
SSIDataPut(SSI2_BASE, TxDataArray[bytesProcessed]);
//chill out for a bit
while(SSIBusy(SSI2_BASE)); //look into this
SSIDataGet(SSI2_BASE, &RxDataArray[bytesProcessed]);
bytesProcessed++;
}
}
uint8_t AIS328DQ::getWhoAmI()
{
uint8_t whoAmI;
read(2, WHO_AM_I);
whoAmI = RxDataArray[1] & 0x000000FF; //should be in index 1 of array
return whoAmI;
}
Any help is greatly appreciated. Thanks!


