2018-01-20 11:18 AM
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.
#i2c-busy2018-05-28 02:58 AM
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.
2018-06-13 10:04 PM
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.