2020-05-07 10:53 AM
data[0]=0B10001111;
data[1]=0B00000000;
data[3]=0B00000000; //this is not needed but i get the default answer here
SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE3));
digitalWrite(10, LOW);
delay(10);
for (size_t i = 0; i < datalen; i++)
{
data[i] = SPI.transfer(data[i]);
}
digitalWrite(10, HIGH);
SPI.endTransaction();
2020-05-07 07:04 PM
a littke empathy here. what chip is spi master?
remember spi receives a byte wheb one is sent. of course the first received correspond to the subaddress being sent. if the spi has hw fifo, it will be saved for you to read first.not all stm32 for example have spi fifos....
2020-05-08 01:04 AM
sorry for littke emphathy, was not my intention. Thank you for your quick response.
My SPI Master is the ATMEGA 328 on Arduino Nano.
The Problem with the response via SPI ist, that the second answer (data[1]) from the Sensor is not the expected answer.
I think it might be a Sensor specific problem. When I try this code via the Arduino IDE and try to read the register in a loop i get the expected answer. But with c++ with a single request to the register i dont get the expected answer.