cancel
Showing results for 
Search instead for 
Did you mean: 

SAI Function call generates unexpected data stream

Kewin_J
Associate II

Hello Board,

I hope you are all having a great summer. I am currently trying to configure the 144 devolopment board with the STM32H723zg chip, to run the built in SAI peripheral. Specifically I want to transmit a frame of 256 bits, with 16 slots and slot data size being 16 bit. I have set the first 9 channels to be active, and the remaining to be inactive, see screen shots or attached file. 

Kewin_J_0-1754294935646.pngKewin_J_1-1754294961236.pngKewin_J_2-1754294984806.png

After, configuration I went to main.c and created a frame of 16 slots, and filled the first 9 slots with hex 0x3FFF (0011 1111 1111 1111) and remaining inactive slots with 0. I then called the HAL_SAI_Transmit, and implemented a short delay after, in order to single out the frames being send through the serial data line.

Kewin_J_3-1754295150919.png

When proping using my osciliscope, I found that binary clock and frame clock works as expected operating at 8.192 MHz and 32kHz respectively. However, I also found that the SDATA seem to send more then one data frame, and that all the data is corrupted, or not looking like I expected. Below I took a image of the osciliscope readings, the green is the SDATA and the orange pulse is the frame clock. 

Kewin_J_4-1754295494571.jpeg

So in short, the SDATA sends unexpected data, and I do not have any idea why. I have tried a lot of different things, and read the reference manual, but I can´t find any good explanation. Hope you can take time out to help me solve this.

Thanks.

 

 

 

 

1 REPLY 1
waclawek.jan
Super User

SAI is not like SPI, waiting for data to generate clock. Rather, as soon as you enable it, it generate clocks inifintely, and if you don't feed it by data, it underflows but keeps transmitting, probably the last datum you wrote into.

I don't know what does the Cube/HAL function do, nor do I care - it's open source so you can look it up, or simply don't use it and write your own code doing what you want it to do.

Generally, there's little reason to use SAI without DMA feeding data continuously into it.

JW