cancel
Showing results for 
Search instead for 
Did you mean: 

[STM32L4] I2C HAL read register problem

zenobik
Associate II
Posted on May 31, 2016 at 08:32

Hi,

I'm trying to read register in my accelerometer FXOS8700. I'm using code below on STM32L476:

uint8_t FXOS8700_ReadReg(uint8_t reg) {
uint8_t value=0;
HAL_I2C_Master_Transmit(&hi2c1, FXOS8700CQ_SLAVE_ADDR, &reg, 1, 100);
HAL_I2C_Master_Receive(&hi2c1, FXOS8700CQ_SLAVE_ADDR, &value, 1, 100); 
return value;
}

HAL library generate STOP between transmit and receive function. I think this is my problem, because in FXOS8700 datasheet STOP is only on the end of whole operation. Is it possible to disable this STOP signal between transmit and receive function ?
1 REPLY 1
Amel NASRI
ST Employee
Posted on June 01, 2016 at 12:02

Hi robert.o,

Usage of functions  HAL_I2C_Mem_Read and HAL_I2C_Mem_Write (I2C driver) or the ones available in SMBUS driver may be helpful for you.

I recommend you to review them.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.