STMicroelectronics / stm32l4xx_hal_driver

Provides the STM32Cube MCU Component "hal_driver" of the STM32L4 series.
BSD 3-Clause "New" or "Revised" License
35 stars 15 forks source link

TX IRQ remains active after HAL_I2C_Mem_Read_DMA #7

Closed accabog closed 1 year ago

accabog commented 1 year ago

Because HAL_I2C_Mem_Read_DMA MemAddress transmission is based on TX IRQ

https://github.com/STMicroelectronics/stm32l4xx_hal_driver/blob/a4d4011e08abea42cb6cbb7764e1a0c4e91c6fb5/Src/stm32l4xx_hal_i2c.c#L3079 neither I2C_Mem_ISR_DMA nor I2C_ITMasterCplt will not disable the TX IRQ after the data transfer https://github.com/STMicroelectronics/stm32l4xx_hal_driver/blob/a4d4011e08abea42cb6cbb7764e1a0c4e91c6fb5/Src/stm32l4xx_hal_i2c.c#L5937 Therefore, if a non-IT based transmission such as HAL_I2C_Mem_Write will follow, a TX irq will be triggered without any interrupt callback defined, therefore the IRQ cannot be cleared and results in the program stuck in I2C ISR

One solution is to call I2C_Disable_IRQ(hi2c, I2C_XFER_TX_IT); also for the state HAL_I2C_STATE_BUSY_RX in I2C_ITMasterCplt

HBOSTM commented 1 year ago

hello @accabog ,

Thank you again for this contribution, This point analyzed here. I will get back to you as soon as I have any updates.

Best Regards,

HBOSTM commented 1 year ago

ST Internal Reference: 145679