STM32WBA65 HAL_SAI_Transmit_DMA not transmitting all data
Hello,
I am having trouble with a call to HAL_SAI_Transmit_DMA() to transfer data to our audio codec.
- Buffer stored in RAM: unsigned char sweep_tone[80000]. For the sake of this demo, I've filled the buffer with 16-bit samples counting from 0 - 39999.
- The SAI interface is configured for 16KHz, 16-bit samples, mono (i.e., data is the same on both channels)
- When I call HAL_SAI_Transmit_DMA(&hsai_BlockB1, pBuffer, 500); the first 500 samples are continuously transferred, as expected. I confirmed this by monitoring the I2S signal with a Saleae.
- However, when I call HAL_SAI_Transmit_DMA(&hsai_BlockB1, pBuffer, 40000); the I2S only shows the values 0 to 7231 being clocked out.
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
