Associate III
September 24, 2020
Solved
STM32F4 Is this BUG? I2S LOOP BACK TEST FAILS in 24Bit Mode. Crush DMA pointer etc. (source code attached)
- September 24, 2020
- 8 replies
- 3601 views
I wrote I2S Loop back test program. I2S2 as Master Transfer mode and I2S3 as Slave Receive mode. (Proto for ADC in and DAC out.)
It works OK when 16bit in 16bit frame. However, in 24 bit in 32bit frame, DMA pointer etc. are corrupted.
With step-by-step trace, I found crushing point in stmf4xx_hal_i2s.c.
Is this BUG or my program is wrong???
Many thanks in advance,
K.A.
Gist of the program is below and screen shot of IDE is attached.
int main(void) {
....
HAL_I2S_Receive_DMA(&hi2s3, (uint16_t *) ADC_Data, (uint16_t) (BUF_LEN*2) * 4) ; // (16bit*2)*stereo*double buffer
while (1)
{
while ((&hi2s2)->State != HAL_I2S_STATE_READY) ;
if (HAL_I2S_Transmit_DMA(&hi2s2, (uint16_t*) Out_buf, (uint16_t) (BUF_LEN*2) * 2) != HAL_OK) {
Error_Handler();
}
}
}
/********** call back **********/
void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef * hi2s3) {
ADC1_ptr = BUF_LEN*2 ;
}
void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef * hi2s3) {
ADC1_ptr = 0 ;