Skip to main content
ELaha
Associate
August 18, 2019
Solved

HAL_SAI_Receive_DMA doesn't start the DMA

  • August 18, 2019
  • 3 replies
  • 1595 views

Platform: STM32WB55 discovery board connected to I2S codec.

My mission: To receive data from the codec using DMA transfer.

Calling to HAL_SAI_Receive function returns the data correctly so I guess that everything is configured correctly.

When calling to HAL_SAI_Receive_DMA, hdma->Instance->CNDTR stays on the same initial value.

When debugging the code and running the HAL functions in single step - I do get the half full interrupt and the buffer contains the correct values. So again - I guess that everything is configured correctly.

The base code is generated with CubeMX.

HAL_SAI_Receive_DMA is called from the main loop, so I guess it is not related to interrupt priority issues.

Any other ideas?

Thanks!

This topic has been closed for replies.
Best answer by ELaha

Issue solved.

Due to high I2S clock frequency (~12Mhz), an AFSDET interrupt occurred and aborted the DMA transfer before it even started.

Reducing the clock frequency to ~2Mhz solved this issue.

I didn't check if 12Mhz clock should be supported when SAI1 clock mux is set to 48Mhz, but in fact - the HAL drivers behave differently.

Thanks.

3 replies

waclawek.jan
Super User
August 18, 2019

Read out and check the SAI and DMA registers, including the DMA status register. Compare between working and not working case.

JW

ELaha
ELahaAuthorAnswer
Associate
August 19, 2019

Issue solved.

Due to high I2S clock frequency (~12Mhz), an AFSDET interrupt occurred and aborted the DMA transfer before it even started.

Reducing the clock frequency to ~2Mhz solved this issue.

I didn't check if 12Mhz clock should be supported when SAI1 clock mux is set to 48Mhz, but in fact - the HAL drivers behave differently.

Thanks.

waclawek.jan
Super User
August 19, 2019

Thanks for coming back with the solution.

I'm not sure why do you see AFSDET interrupt, as it should occur only in slave mode, but I don't know exactly what do you do and I'm definitively not going to investigate Cube/HAL's workings.

Please mark your post as "Best" so that the thread is marked as solved.

JW