cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_SAI_Receive_DMA doesn't start the DMA

ELaha
Associate

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!

1 ACCEPTED SOLUTION

Accepted Solutions
ELaha
Associate

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.

View solution in original post

3 REPLIES 3

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

JW

ELaha
Associate

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.

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