Hi!
I'm using the LaunchPad CC2642R1/CC2652R1 with the accelerometer LIS2DH and i tested the "who am i" (0x33) register to validate the protocol but when i tried read another register i had the same response that "who am i" (0x33) register. Could you help me with this problem or give me some ideas to solve it?
//transmitBuffer
transmitBuffer[0] = ((0x80) | WHO_AM_I_ACELEROMETER);
transmitBuffer[1] = (0x00);
//receiveBuffer
receiveBuffer[0] = (0x00);
receiveBuffer[1] = (0x00);
//transaction
spiTransaction.count = 2;
spiTransaction.txBuf = (void *)transmitBuffer;
spiTransaction.rxBuf = (void *)receiveBuffer;
transferOK = SPI_transfer(spi, &spiTransaction);
if (!transferOK) {
// Error in SPI or transfer already in progress.
while(1);
}
//transmitBuffer
transmitBuffer[0] = ((0x00) | CTRL_REG1); //Write
transmitBuffer[1] = (0x97);
//receiveBuffer
receiveBuffer[0] = (0x00);
receiveBuffer[1] = (0x00);
//transaction
spiTransaction.count = 2;
spiTransaction.txBuf = (void *)transmitBuffer;
spiTransaction.rxBuf = (void *)receiveBuffer;
transferOK = SPI_transfer(spi, &spiTransaction);
if (!transferOK) {
while(1);
}
transmitBuffer[0] = ((0x80) | CTRL_REG4);
transmitBuffer[1] = (0x00);
//receiveBuffer
receiveBuffer[0] = (0x00);
receiveBuffer[1] = (0x00);
//transaction
spiTransaction.count = 2;
spiTransaction.txBuf = (void *)transmitBuffer;
spiTransaction.rxBuf = (void *)receiveBuffer;
transferOK = SPI_transfer(spi, &spiTransaction);
if (!transferOK) {
while(1);
}
Thank you in advance.
Best regards,
Tania