cancel
Showing results for 
Search instead for 
Did you mean: 

LIS3DSH SPI returning only 0s

jmartinezlahoz
Associate II

I am working in a project with the LIS3DSH accelerometer. I have been working with it for some months and had no problems.

void LIS3DSH_Class::enableAcc(byte _speed, byte _antialiasingFilter){
	digitalWrite(CS_LIS3DSH, LOW);
	SPI1.transfer(CTRL_REG4 | WRITE_MODE);
	SPI1.transfer((_speed<<4) | 0x7);
	digitalWrite(CS_LIS3DSH, HIGH);
	
	delay(1);
	
	digitalWrite(CS_LIS3DSH, LOW);
	SPI1.transfer(CTRL_REG3 | WRITE_MODE);
	SPI1.transfer(0xC8);
	digitalWrite(CS_LIS3DSH, HIGH);
	
	delay(1);
	
	digitalWrite(CS_LIS3DSH, LOW);
	SPI1.transfer(CTRL_REG5 | WRITE_MODE);
	SPI1.transfer(_antialiasingFilter<<6);
	digitalWrite(CS_LIS3DSH, HIGH);
	
	delay(1);
	
	digitalWrite(CS_LIS3DSH, LOW);
	SPI1.transfer(FIFO_CTRL_REG | WRITE_MODE);
	SPI1.transfer( 0 );
	digitalWrite(CS_LIS3DSH, HIGH);
}
 
 
 
void  LIS3DSH_Class::readRawAcc(int16_t *x, int16_t *y, int16_t *z){
	digitalWrite(CS_LIS3DSH, LOW);
	SPI1.transfer(OUT_X_L | READ_MODE);
	*x = (SPI1.transfer(0)) | (SPI1.transfer(0)<<8);
	*y = (SPI1.transfer(0)) | (SPI1.transfer(0)<<8); 
	*z = (SPI1.transfer(0)) | (SPI1.transfer(0)<<8);
	digitalWrite(CS_LIS3DSH, HIGH);
}

A month ago I made a new order to Mouser with more of this components, the component reference was exactly the same.

However, the accelerometers received in the last order don't seem to be working.

At first I supposed it was a soldering issue, so I soldered one in an empty PCB and checked for the internal diodes. This way I ensured it was not this problem.

Then I connected the oscilloscope to the CLK, MOSI and MISO lines to check the SPI communication. The CLK and MOSI lines seem normal, but MISO only gives 0s.

I have tried reading every LIS3DSH's register in all four SPI modes and none of them returns anything apart from 0s.

0690X000009jvXDQAY.jpg

Top channel is CLK and bottom channel is MISO.

The LIS3DSHs I have from older orders are working correctly in the same circuit with the same code. The only difference I can see is in the top letters. Old one is, if I can read ir correctly, 2804 DSH6 UOHM; while new one is 2903 DSHT XJDT.

5 REPLIES 5
Eleon BORLINI
ST Employee

Hi @jmartinezlahoz​ , from the oscilloscope scale it seems you are running at VddIO level of 4V. I suggest you to decrease the Vdd or VddIO and then try again the SPI communication. Regards

jmartinezlahoz
Associate II

Thanks for the response, I adjusted the VddIO level to 3,3V, but it solved nothing as you can see.

0690X000009k65uQAA.jpg

In these photos I am using an external DC supply to test the communications. In the board I use a buck power supply, and I have ensured that it works correctly at 3V3. All the other components work fine in the board, including the old LIS3DSHs.

​I suggest you to try with lower Vdds... in the meantime I'll check the lot with that trace code, if I can gather useful information. But how many samples did you buy? Regards

jmartinezlahoz
Associate II

I tried with lower Vdds, but it still doesn't work. I bought 23 samples, I tried 6 or 7 of them, and none seem to work.

Eleon BORLINI
ST Employee

Can you try to desolder one old LIS3DSH and solder one from the new batch, and check if in the same condition is working? Can you confirm it was a LIS3DSH and not a LIS3DH? Regards