cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F7 SAI SPDIF TX channel status / frame count

LCE
Principal

Dear STM32-SPDIF-TX experts,

I'm working with a STM32F767 on a Nucleo-144 board.

Creating a sine, sending data at 24bit/192kHz via DMA / SAI 2B, everything fine.

Filling the output buffer for SPDIF within the HAL_SAI_TxHalfCpltCallback() & HAL_SAI_TxCpltCallback() functions. Works like a charm.

Now the problem:

I need to add SPDIF channel status data, that actually works too, but with one problem:

the frame count seems to be delayed by 22 bytes.

For testing I send only incremented values 1..24 (left channel, right channel + 0xA0), but what I get on the receiver side always starts like that:

22 23 24 1 2 ...

The frame counter is always reset to 0 before HAL_SAI_Transmit_DMA(), incremented in the ISRs, and reset to 0 when it reaches 192.

All the bytes I receive are okay, it's just the order of the bytes.

I do not want a "workaround", I'd like to know what I am doing wrong, or maybe if there is a problem with the DMA / SPDIF TX combination.

So, any ideas?

Thanks in advance!

1 REPLY 1
LCE
Principal

Okay, just found out that this frame count "delay" depends on the DMA buffer size:

when I set the frame counter to half DMA buffer size before starting, then the channel status data order is okay.

And I guess my problem with DMA-TX is, that I need to fill the TX buffer before starting DMA TX... ouch!

(I'm mostly working on the "receiving side" 😉 )