2020-08-16 08:00 AM
Hi!
I have tried to use I2S onn STM32H750 and DMA has no success. I can transfer without problem data by standard HAL_I2S_Transmit but HAL_I2S_Transmit_DMA results in Error callback being fired although function itself completes with HAL_OK.
I2S Config
hi2s2.Instance = SPI2;
hi2s2.Init.Mode = I2S_MODE_MASTER_TX;
hi2s2.Init.Standard = I2S_STANDARD_PCM_SHORT;
hi2s2.Init.DataFormat = I2S_DATAFORMAT_32B;
hi2s2.Init.MCLKOutput = I2S_MCLKOUTPUT_ENABLE;
hi2s2.Init.AudioFreq = I2S_AUDIOFREQ_48K;
hi2s2.Init.CPOL = I2S_CPOL_LOW;
hi2s2.Init.FirstBit = I2S_FIRSTBIT_MSB;
hi2s2.Init.WSInversion = I2S_WS_INVERSION_DISABLE;
hi2s2.Init.Data24BitAlignment = I2S_DATA_24BIT_ALIGNMENT_LEFT;
hi2s2.Init.MasterKeepIOState = I2S_MASTER_KEEP_IO_STATE_DISABLE;
DMA Config:
hdma_spi2_tx.Instance = DMA1_Stream5;
hdma_spi2_tx.Init.Request = DMA_REQUEST_SPI2_TX;
hdma_spi2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_spi2_tx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_spi2_tx.Init.MemInc = DMA_MINC_ENABLE;
hdma_spi2_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
hdma_spi2_tx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
hdma_spi2_tx.Init.Mode = DMA_CIRCULAR;
hdma_spi2_tx.Init.Priority = DMA_PRIORITY_HIGH;
hdma_spi2_tx.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
And when I fire:
res = HAL_I2S_Transmit_DMA(&hi2s2, (uint16_t*)buf, buf_size);
I end up with Callback
void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s)
being called.
Other callbacks like HAL_I2S_TxHalfCpltCallback or HAL_I2S_TxCpltCallback never get called.
Is there any extra bit I need to do? Can I run any other diagnostics? I see that DMA interrupt is called and there is TransmitError happening.
Solved! Go to Solution.
2020-08-16 08:30 AM
Found a problem. For those not familiar with H7 series like me, the DMA operates only from D1/D2 memories and therefore its buffer needs to be allocated there.
2020-08-16 08:30 AM
Found a problem. For those not familiar with H7 series like me, the DMA operates only from D1/D2 memories and therefore its buffer needs to be allocated there.