Skip to main content
ELaha
Associate
Aug 18, 2019 15:44 UTC
Solved

HAL_SAI_Receive_DMA doesn't start the DMA

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.
ELaha
ELahaBest answer
Associate
Aug 19, 2019 05:41 UTC

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
Aug 18, 2019 20:43 UTC

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

JW

ELaha
ELahaAuthorBest answer
Associate
Aug 19, 2019 05:41 UTC

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
Aug 19, 2019 07:56 UTC

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