AnsweredAssumed Answered

possible bug in HAL_I2C_Mem_Read_IT and HAL_I2C_Mem_Read_DMA?

Question asked by noobee on Apr 6, 2015
Latest reply on Apr 12, 2015 by yvraut.gerard
hey all

trying to get basic interrupt-based and DMA-based I2C code to run.

the setup is a stm32f103cb with mpu6050 connected via I2C. i followed the HAL I2C examples except that there are none specifically for HAL_I2C_Mem_Read_IT and HAL_I2C_Mem_Read_DMA (not even on the public internet). in any case, i got it mostly working except if i tried to transfer a single byte from the device.

the following call fails.
HAL_I2C_Mem_Read_IT(&hi2c2,
  (uint16_t) MPU6050_ADDRESS,
  (uint16_t) MPU_RA_WHO_AM_I,
  I2C_MEMADD_SIZE_8BIT,
  (uint8_t *) buf,
  1);

but, the following call works:
HAL_I2C_Mem_Read_IT(&hi2c2,
  (uint16_t) MPU6050_ADDRESS,
  (uint16_t) MPU_RA_WHO_AM_I,
  I2C_MEMADD_SIZE_8BIT,
  (uint8_t *) buf,
  6);

the only difference is the size of the transfer (1 byte fails, 6 byte works).

i also tried HAL_I2C_Mem_Write_IT, which seems to be working for 1 byte writes. i have not tried HAL_I2C_Mem_Write_DMA.

the failure mode in both cases seem to be related to timing out waiting for the I2C controller to be not BUSY.

so, does any one have a working example or theory what's wrong? is there a bug filing process for ST? so far, i found 3 issues with the stm32cube HAL in 2 days (the other one is related to remapping JTAG pins for GPIO, the generated code does not work), making me a little nervous and wonder if i should stick to SPL instead...

Outcomes