2018-02-28 12:02 AM
Hello,
I'm currently testing the LIS2DH12 accelerometer, which is mounted on the MKI151V1. The board is connected to a SPI/I2C device from National Instruments because I want to integrate the sensor in a LabVIEW measurement software. First of all, I would like to mention, that I'm a beginner in working with SPI, so it is possible that I make a simple mistake.
In LabVIEW, I first open a SPI configuration (Set Chip Select, Clock Rate, Clock Polarity, Clock Phase) followed by the Read/Write Command. At the end of the communication, I close the SPI configuration again. The corresponding R/W LabVIEW-VI needs an hex-array as input and returns the answer of the SPI-Slave, if necessary, in an hex-array output.
Every command of the LIS2DH12 consists of 8bit. Thus every array index represents one byte (hex format).
In case of a reading, the first array index represents the read command (RW bit; MS bit; register address). The following array indices have to be an optional hex-number for the number of register data I want to receive.
In case of a writing, the first index represents the write command and the following indices represent the data I want to write in the register/s.
As an example, when I want to read register 'WHO_AM_I' (0Fh): I send the input array '8Fh;00h' (index 0; index 1) and receive the output array '8Fh;33h', which is the right answer for this register. So far, everything works fine.
Finally I will come to the actual problem. If I repeat this read command the accelerometer answers with 'FFh'. This problem occurs with every R/W-command from any register, no matter what time is in between multiple R/W-commands. When I connect the sensor for the first time, it also responds with 'FFh'.
Do you have any ideas what the reason for this behavior is?
Does anyone have some experience in working with the SPI/I2C device from National Instruments?
I would like to thank you in advance.
Best Regards,
Pascal
#lis2dh12 #spi-communication #labview2018-02-28 12:25 AM
Do you control the CS pin?
Can you capture the communication on SPI bus by a scope or logic analyzer?
2018-02-28 04:46 AM
Do you control the CS pin?
I'm not completely sure what the NI device really does. I think it sets the CS line to low, when the transmission starts and sets it high again after the transmission is finished, as described in the manual of the LIS2DH12.
Can you capture the communication on SPI bus by a scope or logic analyzer?
Yes, I will try this within the next days.
2018-03-06 11:15 PM
Yesterday I captured the SPI communication and I was able to solve the problem on my own. Now everything works fine.
Nevertheless, thank you very much.