Question
I am working on STM32H743 micro operating as a slave I2C device. I am able to write to the slave device by a master I2C device but I can't seem to read.
I have done some investigation and arrived that the problem is with the "DIR" bit in
the Interrupt Status register not firing to indicate whether to do a Read.
uint32_t isr_trace[64];
int isr_count = 0;
void I2C2_EV_IRQHandler(void)
{
isr_trace[isr_count++] = I2C2->ISR; /* debug to check ISR status on entry*/
if (!(I2C2->ISR & I2C_ISR_DIR_Msk)) /* Master is writing memory address.*/
{
while (!(I2C2->ISR & I2C_ISR_RXNE_Msk)) {}
RX_buffer[RX_count++] = I2C2->RXDR;
}
else /* Master is requesting data from memory. */
{
for (int i = 0; i < 4; i++)
{
while (!(I2C2->ISR & I2C_ISR_TXE_Msk)) {}
I2C2->TXDR = TX_buffer[i];
}
}
I2C2->ICR |= I2C_ICR_STOPCF;
}However if I then set a software break point before reading the I2C2->ISR register
as shown below here.
void I2C2_EV_IRQHandler(void)
{
__BKPT(0);
isr_trace[isr_count++] = I2C2->ISR; /* debug to check ISR status on entry*/
...
}The I2C2->ISR is updated to show the "DIR" bit correctly. Many thanks in advance.
