cancel
Showing results for 
Search instead for 
Did you mean: 

bug in HAL I2S Full Duplex STM32Cube_FW_F4_V1.16.0

sea trix
Associate
Posted on September 06, 2017 at 09:30

I'm using I2s2 and I2s2ex in Full Duplex  mode,set the DMA in DMA_CIRCULAR mode,but  

HAL_I2SEx_TxRxCpltCallback can't be called,so I modify as follows.Is this a bug?

static void I2SEx_TxRxDMACplt(DMA_HandleTypeDef *hdma)

{

I2S_HandleTypeDef* hi2s = (I2S_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent;

/* if DMA is not configured in DMA_CIRCULAR mode */

if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0U)

{

if (hi2s->hdmarx == hdma)

{

/* Disable Rx DMA Request */

if (((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG) == I2S_MODE_MASTER_TX) ||\

((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG) == I2S_MODE_SLAVE_TX))

{

CLEAR_BIT(I2SxEXT(hi2s->Instance)->CR2,SPI_CR2_RXDMAEN);

}

else

{

CLEAR_BIT(hi2s->Instance->CR2,SPI_CR2_RXDMAEN);

}

hi2s->RxXferCount = 0U;

if (hi2s->TxXferCount == 0U)

{

hi2s->State = HAL_I2S_STATE_READY;

HAL_I2SEx_TxRxCpltCallback(hi2s);

}

}

if (hi2s->hdmatx == hdma)

{

/* Disable Tx DMA Request */

if (((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG) == I2S_MODE_MASTER_TX) ||\

((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG) == I2S_MODE_SLAVE_TX))

{

CLEAR_BIT(hi2s->Instance->CR2,SPI_CR2_TXDMAEN);

}

else

{

CLEAR_BIT(I2SxEXT(hi2s->Instance)->CR2,SPI_CR2_TXDMAEN);

}

hi2s->TxXferCount = 0U;

if (hi2s->RxXferCount == 0U)

{

hi2s->State = HAL_I2S_STATE_READY;

HAL_I2SEx_TxRxCpltCallback(hi2s);

}

}

}

else

{

if (hi2s->hdmarx == hdma)

{

hi2s->RxXferCount = 0U;

if (hi2s->TxXferCount == 0U)

{

hi2s->State = HAL_I2S_STATE_READY;

HAL_I2SEx_TxRxCpltCallback(hi2s);

}

}

if (hi2s->hdmatx == hdma)

{

hi2s->TxXferCount = 0U;

if (hi2s->RxXferCount == 0U)

{

hi2s->State = HAL_I2S_STATE_READY;

HAL_I2SEx_TxRxCpltCallback(hi2s);

}

}

}

}
1 REPLY 1
rchrdlyon1
Associate II
Posted on September 14, 2017 at 12:04

Just discovered STM32Cube_FW_F4_V1.16.0 has broken our product. A STM32F407 processor is communicating with a MAX9860 codec via full duplex I2S using DMA with circular addressing. It worked well, but updating the HAL library has broken it badly. The problem that HAL_I2SEx_TxRxCpltCallback will never be called from I2SEx_TxRxDMACplt. It is a bug or omission in the HAL code. There is no mention in the release notes that circular buffers cannot be used with i2s DMA.

Also, when using circular addressing it is good to have a HAL_I2SEx_TxRxHalfCpltCallback function as well. Allows for easy seamless i2S transfer using DMA with minimal time constraints.

So we have to revert back to STM32Cube_FW_F4_V1.13.0 or modify HAL.