cancel
Showing results for 
Search instead for 
Did you mean: 

Read\Write LIS2DH12 with I2C using DMA

dherbst
Associate
Posted on November 17, 2017 at 15:13

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?

1 REPLY 1
Ansic 121
Associate II
Posted on April 19, 2018 at 16:33

I am facing same problem.

Have you solved this problem?