2024-11-23 07:29 PM
Hello,
I am implementing my own I2C drivers based on the LL drivers provided by stm32g031xxxx (STM is the only master) Transmission and Reception all work very well but I am trying to get away with some optimization by starting a I2C read from a slave at one point and actually reading the byte later when an event happens, this is allowed as long as the CLK line is stretched indefinitely in between messages, which I am sure I do. (I2C timeout is disabled)
I should mention I am aware that the I2C peripheral will immediately read a byte when a start condition is triggered, so what I have is a dummy byte being sent through I2C while the second byte to be transferred is the one of interest to me. This second byte will not be sent through I2C until I read the RXDR register, resetting RNXE and making the peripheral clock out the byte of interest without any time wasted sending a start condition or clocking out the dummy byte through I2C.
This works normally, I send a start condition and about 1ms later I am able to read the byte without the I2C timing out. But when there is a larger gap (I am estimating about 20ms or so), the STM tells me the RXNE flag is not set and that there is no byte left to read!
I have already made sure there isnt a random place I am reading RXDR and that I have no other errors flagged (at least per the peripheral ISR register) so I am at a loss.
My one idea is to simply reset the communication I have every 2ms or so if my code does not read the RXDR register, but this seems cumbersome. I also dont want to design around errors until I'm sure it is not my code (which it may very well be). Any ideas?