STM32H743ZI Bizzare behavior from I2C with Reload = 1
Hi everyone,
Trying to create an eeprom API based on the AT24CM01 ASIC chip. I got the Byte write working no problem, however the IC is capable of doing sequential writes up to 256 bytes. The way I am doing this is setting the 'RELOAD' value within the I2C to '1'. While debugging I notice that the TCR flag sets itself even though I havent read the number of bytes transferred yet.
Here is the code in question:
All this is doing is checks if I am going to be writing more than 256 bytes and if so when I reach the max number of bytes (0xFF/255) I just reload the NBYTES with another 0xFF to send another "unlimited" amount of data. The problem is the TCR flag somehow sets itself before getting to the while loop waiting for the TXE, and wont ready the TXE flag anymore due to TCR flag being set, thus having me be stuck in it.
for (DATA_FRAME_CNT; DATA_FRAME_CNT < DATA_FRAME_LEN; DATA_FRAME_CNT++) {
if (DATA_FRAME_CNT == 0xFFU) {
LL_I2C_SetTransferSize(I2C_BUS, 0xFFU);
}
*(uint8_t*)(&I2C_BUS->TXDR) = DATA_FRAME[DATA_FRAME_CNT];
while (LL_I2C_IsActiveFlag_TXE(I2C_BUS) == 0); -> getting stuck here
}I found out if I halt the CPU, and manually write the NBYTES myself, I can see the TCR flag clear and no longer sets itself and exits out of the for loop.
The state of the I2C registers when the CPU is halted and stuck at the while loop, after NBYTES has been set again to 0xFF.

My intention of this code is to write more than 256 Bytes by once reaching the 255 byte mark just simply reload the NBYTES register with another 0xFF and have the for loop exit itself and then initiate a stop condition at the end.
The reason I am sending more than 256 bytes here because of the eeprom word address bytes is included in the transcation so a total of 258 Bytes needs to be sent (256 worth of data and 2 Address Bytes).
Any advice? I am stumped.