cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_SAI_Transmit_IT data

carloV
Associate II

I'm using the NUCLEO board NUH723 to develop a project and I need to understand better how the HAL_SAI_Transmit_IT works.

In my code I use the HAL_SAI_Transmit_IT to send data to the SAI1 interface --> 48KHz, stereo,32bit:

I have to send two buffer of 128 word (Arxbuff31 and Brxbuff31, stereo,32bits),

 

uint8_t DAC_Buffer[BUFFER_SIZE]; // __attribute__ ((aligned (4)));

uint8_t ADC_Buffer[BUFFER_SIZE]; // __attribute__ ((aligned (4)));

int32_t *p31;

q31_t Arxbuff31[128],Brxbuff31[128];

 

 

p31=(q31_t *)DAC_Buffer;

for(x=0;x<128;x++){

*p31++=Arxbuff31[x];

*p31++=Brxbuff31[x];

}

----

----

while(!RxDataReady);

status=HAL_SAI_Transmit_IT(&hsai_BlockA1,DAC_Buffer,256);

----

RxDataReady=0;

----

In what way the data must be stored in the output buffer (DAC_Buffer) for both the channels ?

(I suppose Left4bytes,Right4bytes,Left4bytes,....)

The "size" parameter has to set to the 2*128 ?

 

Thank you, Luigi

 

1 ACCEPTED SOLUTION

Accepted Solutions
Saket_Om
ST Employee

Hello @carloV 

 

The HAL_SAI_Transmit_IT function is used to transmit data via the SAI interface in non-blocking mode with interrupt. This function takes a buffer and the number of audio data items to be sent.

In your case, you are using a stereo configuration with 32-bit data width. The data in the buffer should be interleaved for stereo transmission, which means that the left and right channel data should alternate in the buffer. Your assumption is correct; the data should be stored as Left4bytes, Right4bytes, Left4bytes, Right4bytes, and so on.

Regarding the "size" parameter for the HAL_SAI_Transmit_IT function, it should be set to the total number of audio data items to be sent. Since you have two channels (stereo) and each channel has 128 data items, the total size would indeed be 2 * 128, which accounts for both the left and right channels.

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

View solution in original post

1 REPLY 1
Saket_Om
ST Employee

Hello @carloV 

 

The HAL_SAI_Transmit_IT function is used to transmit data via the SAI interface in non-blocking mode with interrupt. This function takes a buffer and the number of audio data items to be sent.

In your case, you are using a stereo configuration with 32-bit data width. The data in the buffer should be interleaved for stereo transmission, which means that the left and right channel data should alternate in the buffer. Your assumption is correct; the data should be stored as Left4bytes, Right4bytes, Left4bytes, Right4bytes, and so on.

Regarding the "size" parameter for the HAL_SAI_Transmit_IT function, it should be set to the total number of audio data items to be sent. Since you have two channels (stereo) and each channel has 128 data items, the total size would indeed be 2 * 128, which accounts for both the left and right channels.

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar