cancel
Showing results for 
Search instead for 
Did you mean: 

ST LIS2DE12 WHO_AM_I?

antonius
Senior

Dear ST Community Members,

I tried to understand...page 25 ST LISDE12.pdf

..................

Data are transmitted in byte format (DATA). Each data transfer contains 8 bits. The number

of bytes transferred per transfer is unlimited. Data is transferred with the Most Significant bit

(MSb) first. If a receiver can’t receive another complete byte of data until it has performed

some other function, it can hold the clock line, SCL low to force the transmitter into a wait

state. Data transfer only continues when the receiver is ready for another byte and releases

the data line. If a slave receiver doesn’t acknowledge the slave address (i.e. it is not able to

receive because it is performing some real-time function) the data line must be left HIGH by

the slave. The master can then abort the transfer. A low-to-high transition on the SDA line

while the SCL line is HIGH is defined as a STOP condition. Each data transfer must be

terminated by the generation of a STOP (SP) condition.

In order to read multiple bytes, it is necessary to assert the most significant bit of the subaddress

field. In other words, SUB(7) must be equal to 1 while SUB(6-0) represents the

address of the first register to be read.

In the presented communication format MAK is Master acknowledge and NMAK is No

Master Acknowledge.

........................

Table 16 to Table 19....

How can I generate SAK and SUB ?

Here's the code I have made :

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, GPIO_PIN_SET);   //ACC_CS =1 I2C MODE
	  HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_RESET); //ACC_A0 =0 SA0=0
    HAL_Delay(100);
//WHO_AM_I, read ,register address 0F 000 1111, 00110011 = 33h page 30 ST LIS2DE12
		
		buffer[0] = 0x0F;
		
		HAL_I2C_Master_Transmit(&hi2c1, 0x31>>1 ,buffer ,1, 100); //transmit one byte to ST LIS2DE12 
//HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout)
 
		// put HAL_I2C_Receive after this give a delay 10ms, how many bytes do I want to read from the register.
   
    HAL_Delay(10);
		HAL_I2C_Master_Receive(&hi2c1, 0x31>>1 ,buffer ,2, 100); //receive one byte to ST LIS2DE12
//HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout)
rawValue = buffer[0]<<8 | buffer[1];  
		//buffer[0] -- MSB
		//buffer[1] -- LSB
		printf("This is from ST LIS2DE12 : %s",rawValue);
		//printf("\r\n");
		//printf("%s",result);
		HAL_Delay(1000);
		

Any clues ?

Thanks

3 REPLIES 3
antonius
Senior

I follow

ST ==> SAD+W ==> SAK ==> SUB  ==> SAK ==> SR ==> SAD+R ==> SAK ==> DATA ==> NMAK ==> SP ----------------> Reading 1 byte from ST LIS2DE12

from Table 18

page 25 ST LIS2DE12 datasheet....

Miroslav BATEK
ST Employee

Subaddress byte (SUB) is automaticaly generated by HAL_I2C_Master_Transmit or HAL_I2C_Master_Receive.

Slave acknowledge (SAK) is generated by the sensor (I2C slave).

antonius
Senior

Thanks for the answer Miroslav,

If I want to make the sensor very sensitive to movement,

which register do we need to change ?

I saw INT2_THS (36h), and INT1_THS (32h), any other registers that I need to change to make it more sensitive ?

Thanks