Why is the overflow flag (OVR) set as soon as the I2S peripheral has been enabled when using I2S2 in Interrupt mode with Nucleo F401RE?
I am trying to use the I2S2 interface in Master Rx mode with the Nucleo 401RE and X-Nucleo-CCA02M2 audio shield. I enable the SPI2 global interrupt in NVIC settings, setup the required GPIOs and generate the code. I want to receive data from the on-board microphones of the audio shield and I want the MCU to generate the clock.
As soon as the I2S peripheral is enabled in the HAL_I2S_Receive_IT() function, which is called once before the infinite while loop (__HAL_I2S_ENABLE(hi2s)), the OVR flag is raised due to which the interrupt handler is serviced only once as the below code in the I2S_IRQHandler is executed -
/* I2S Overrun error interrupt occurred -------------------------------------*/
if (((i2ssr & I2S_FLAG_OVR) == I2S_FLAG_OVR) && (__HAL_I2S_GET_IT_SOURCE(hi2s, I2S_IT_ERR) != RESET))
{
/* Disable RXNE and ERR interrupt */
__HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_RXNE | I2S_IT_ERR));
/* Clear Overrun flag */
__HAL_I2S_CLEAR_OVRFLAG(hi2s);
/* Set the I2S State ready */
hi2s->State = HAL_I2S_STATE_READY;
/* Set the error code and execute error callback*/
SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_OVR);
/* Call user error callback */
#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
hi2s->ErrorCallback(hi2s);
#else
HAL_I2S_ErrorCallback(hi2s);
#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
}Can anyone help me figure out why the overflow flag is getting raised right after the I2S peripheral is enabled and how to get interrupt mode to work with I2S?
