Tool/software:
Hello all,
I am using SPI on the 2800137 launchpad to communicate with a LDC1101.
If I use the SPI_transmitByte() function and pass the appropriate READ/WRITE command along with a register address of the LDC1101, then I can read/write data successfully. For example, this code puts the LDC1101 to sleep mode by writing 0x01 to the START_CONFIG register (address 0x0B).
// Put LDC1101 in sleep mode, so it can be configured appropriately.
GPIO_writePin(pin, 0); // pull state of pin to 0.
SPI_transmitByte(base, WRITE_CMD+START_CONFIG_REGISTER); // put LDC1101 in sleep mode by writing 0x01 to START_CONFIG register at 0x0B
SPI_transmitByte(base, 0x01); // writing 0x01 as indicated in the previous line
GPIO_writePin(pin, 1); // pull state of pin to 1
GPIO_writePin(pin, 0);
SPI_transmitByte(base, READ_CMD+START_CONFIG_REGISTER);
reg_value=SPI_transmitByte(base, 0x00); // transmit dummy data to receive value stored in register address
GPIO_writePin(pin, 1);
ASSERT(reg_value == 0x01);
But, if I configure the launchpad to use SPI in FIFO mode, then I am not getting a valid response back. The receive buffer on the launchpad just contains 0x00FF. The code I am using is the following.
//
// Create send Tx buffer for SPI.
//
uint16_t txData[4] = {0x0B00, 0x0100, 0x8B00, 0x0000}; // transmit buffer --> {write command to 0x0B, data to write, read command to 0x0B, dummy data to send}
uint16_t rxData[4] = {0xAAAA, 0xAAAA, 0xAAAA, 0xAAAA}; // initalised to a dummy value.
while (i < 2)
{
// Poll until there's space in the TX FIFO
while (SPI_getTxFIFOStatus(base) == SPI_FIFO_TXFULL)
{
// Wait for space in TX FIFO
}
// Write data to the TX FIFO
SPI_writeDataNonBlocking(base, txData[i]);
//DEVICE_DELAY_US(1);
i++;
}
// Wait until all data has been sent (TX FIFO is empty)
while (SPI_getTxFIFOStatus(base) != SPI_FIFO_TXEMPTY)
{
// Wait for TX FIFO to empty
}
i=0;
while (i < 2)
{
// Poll until there is data in the RX FIFO
while (SPI_getRxFIFOStatus(base) == SPI_FIFO_RXEMPTY)
{
// Wait for data in RX FIFO
}
// Read data from RX FIFO
rxData[i] = SPI_readDataNonBlocking(base);
//DEVICE_DELAY_US(1);
i++;
}
GPIO_writePin(pin, 1);
What am I missing? Any insights much appreciated.