AnsweredAssumed Answered

Read\Write LIS2DH12 with I2C using DMA

Question asked by herbst.dewald on Nov 17, 2017
Latest reply on Apr 19, 2018 by Ansic 121

Hi, I am trying to read the LIS2DH12 using the I2C and DMA.

I got everything configured via STM32CubeMx. 

 

When I want to read the LIS2DH12 (WHO_AM_I @0x0F) I call:

 

HAL_I2C_Master_Receive_DMA(&hi2c1, (uint16_t)SLAVE_ADDRESS, (uint8_t *)I2CRxBuf, 1);

 

I have defined the below:

 SLAVE_ADDRESS 0x330F   // (slave address 0x33 and read adress 0x0F

char I2CRxBuf[5];

 

I wait for it to complete the receive first:

while (HAL_I2C_GetState(&hi2c1) != HAL_I2C_STATE_READY);

 

Then print the value on the screen. It always stay zero.

 

What am I doing wrong?

Outcomes