cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f746 - I2C Busy flag stuck after a few reads

contact239955_st
Associate II
Posted on January 20, 2018 at 20:18

Hey, I am currently using HAL_I2C_Mem_Read_IT() to read out data of a capacitive touchscreen sensor.

The call works perfectly for the first 10-100 interactions, the interrupt fires HAL_I2C_MemRxCpltCallback() is triggered and my buffer contains valid data.

The problem is that after a couple reads the I2C4 busy gets set to busy, and is never cleared.

My code looks similar to this:

void

HAL_I2C_MemRxCpltCallback(

I2C_HandleTypeDef

*hi2c) {

    test++

;

}

void

GT811_Scan

(

void

) {

    dev_state =  HAL_I2C_Mem_Read_IT(&hi2c4

,

GT811_CMD_RD

,

GT811_READ_XY_REG

,

I2C_MEMADD_SIZE_16BIT

,

touchData

sizeof

(touchData))

;

}

I have 10k pull-up and used CubeMX to generate my initialization code (Which i assume is correct as I can receive data for a bit).

Here is a screenshot of my output:

You can see that the last time shows I2C State :1, followed by no future events.

0690X00000604CSQAY.jpg

#i2c-busy
2 REPLIES 2
just4you
Associate II
Posted on May 28, 2018 at 11:58

Did you solve your problem?

I also had experienced difficulties caused by busy flag.

Other prior interrupt makes some timing troubles I think.

I adjusted my system's interrupt priorities and changed the I2C's interrupt priority as the top.

After regulation of interrupt priorities, I can't meet the busy stuck.

I want my advice would be right on your case.

Posted on June 14, 2018 at 05:04

I just want to mention one more things I recently discovered.

DMA operation of I2C guarantees more stability.

I hope you would try to change your code to DMA.