2025-08-19 6:42 AM
Hello,
I am having trouble with a call to HAL_SAI_Transmit_DMA() to transfer data to our audio codec.
The number 7231 is interesting to me. The size argument to HAL_SAI_Transmit_DMA() is 16 bits, and UINT16_MAX =65535. If there's a conversion someplace in the HAL calls that converts 40000 samples to 80000 bytes, this would overflow to 14465 bytes, which is 7232.5 samples, truncated to 7232, which corresponds to a max value of 7231 being clocked out.
However, I've not found where this overflow could occur, if this is indeed what is going on!
Any ideas?
Thank you,
Jonathan
Solved! Go to Solution.
2025-08-19 7:25 AM
While debugging, step through the code until the write to the DMA's NDTR register. Should be apparent where the overflow occurs.
Ensure your DMA is set to transfer half-words rather than bytes, as 65535 is the max number of items that can be sent through DMA.
2025-08-19 7:25 AM
While debugging, step through the code until the write to the DMA's NDTR register. Should be apparent where the overflow occurs.
Ensure your DMA is set to transfer half-words rather than bytes, as 65535 is the max number of items that can be sent through DMA.
2025-08-19 2:01 PM
Thank you for the response!
On the WBA65, at least, it appears to be the BR1 register that you're referring to, and the BNDT field, which is 16 bits. Interestingly, this is in bytes, not in blocks/item sizes: "BNDT[15:0] is programmed in number of bytes, maximum source block size is 64 Kbytes -1".
So that answers that!