STM32 USB to I2S multi channel - log - ask for help

I'm on leaves traveling Scotland, but I took the lapotop and the development board to do few tests here and there. I experiment with higher sampling frequencies.

I discovered that HAL had a fixed list of "accepted" sampling frequencies, which stops at 192k, and does not allows to reach 384k for tests. That list neither contains all frequencies from both famillies :-(

#define IS_SAI_AUDIO_FREQUENCY(AUDIO) (((AUDIO) == SAI_AUDIO_FREQUENCY_192K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_96K) || \ ((AUDIO) == SAI_AUDIO_FREQUENCY_48K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_44K) || \ ((AUDIO) == SAI_AUDIO_FREQUENCY_32K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_22K) || \ ((AUDIO) == SAI_AUDIO_FREQUENCY_16K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_11K) || \ ((AUDIO) == SAI_AUDIO_FREQUENCY_8K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_MCKDIV))

There still the most usefull ones, but if you want a additional frequencies, you may need to tweak/modify HAL... or use LL for the specific purpose.

At 192k, 16 bits the audio task uC usage is 71%, from 52% for 48k). I imagine that it should be OK for 8 channels, 32bits, 192k.

The CODEC on my board is limited to 96k, I have to do another test for that freq.
 
Those HAL audio frequencies are only used for setting SAI clock parameters to registers. The same register settings can be made directly without HAL. The only downside is that some of these settings are MCU specific which is hidden by HAL. But on the other hand setting registers manually forces you the study the SAI clocking in more detail which in the long run is better.
 
  • Like
Reactions: 1 user
Schema is very simple (see attachment). In my implementation GPIOs and CLK go through digital isolator but that is not absolutely needed. MCK divider is set in register SAI_ACRx. Reference manual has all the required information.

Hello bohrok,

I'm a bit lost between all the types of crystals available for the SAI input clock: crystals, oscillators, TCXOs...

Would you have some examples of references I should look for? what are typical performances for our applications?

JMF
 
Hi, I don't fully understand how are managed by the USB UAC2 the sampling Frequency ranges if only one sampling familly is managed (ex 48-96, 192, but not 44.1-88.2...). Especially with Windows not managing the clock switching feature of UAC2).

In the exemples I have, the declaration is for all range from 44.1 to let's say 192k, with all intermediates from both families.

How should be declared in the descriptor support for only 48k-96k-192k?

Best regards,

JMF
 
And I looked at the Crystals, unfortunatly, I can't get the NZ2520SD from JLCPCB, even using global sourcing (they by directly for you to Mouser, Digikey... a list of about 10 resellers). They only have crystals like that one: https://jlcpcb.com/partdetail/8433486-SX3M49152B10F20TNN/C7431354

I don't evaluate the benefit of using NZ2520SD instead of the cheaper chinese ones, vs the extra burden of multiple sourcing and post assembly soldering.
 
Especially with Windows not managing the clock switching feature of UAC2
IME the UAC2 driver respects the rates reported by the UAC2 clock feature.
How should be declared in the descriptor support for only 48k-96k-192k?
The descriptor declares the clock feature, and the clock feature reports the ranges it supports when requested. IMO the code in linux gadget shows the details quite well https://github.com/torvalds/linux/b...vers/usb/gadget/function/f_uac2.c#L1608-L1637