Skip to main content
BRusl.1
Associate II
May 5, 2023
Question

STM32F723 DISCO, Audio play/record example - SAI interrupts twice fast then expected

  • May 5, 2023
  • 17 replies
  • 4206 views

Hi,

Having STM32F723 DISCO with simple play/record example. Need to process sound by 20ms periods, so I've calculated PCM buffer size as :

```

#define AUDIO_CHANNELS         2

#define AUDIO_PCM_BIT_RESOLUTION    16

#define AUDIO_SAMPLE_LENGTH_MS     20

#define AUDIO_SAMPLE_SIZE        (AUDIO_CHANNELS * (SAMPLE_RATE/1000) * AUDIO_SAMPLE_LENGTH_MS)

#define AUDIO_PERIODS          2

#define AUDIO_BUFFER_SIZE        (AUDIO_SAMPLE_SIZE * AUDIO_PERIODS)

```

So I'm expect the HAL_SAI_TxHalfCpltCallback & HAL_SAI_TxCpltCallback to trigger each 20ms, but it triggers each 10ms:

```

[0000:00:00:00.000] Firmware v1.0 started, h/w rev: 0x1000

[0000:00:00:00.000] System clock: 216 MHz, HCLK/AHB clock: 216 MHz, PCLK1/APB1 clock: 54 MHz, PCLK2/APB2 clock: 108 MHz

[0000:00:00:00.655] SAI clock: 49.142856 MHz

[0000:00:00:00.655] Audio inited: Sample rate: 16000, channels: 2, period length: 20 ms, AUDIO_PCM16BIT_SAMPLE_SIZE: 640, doubled AUDIO_PCM16BIT_BUFFER_SIZE: 1280

[0000:00:00:00.655] Board inited

[0000:00:00:00.655] App started

[0000:00:00:00.655] Generating sine table for 200Hz

[0000:00:00:00.832] Sine table gen completed

[0000:00:00:00.833] Audio started

[0000:00:00:00.843] BSP_AUDIO_OUT_HalfTransfer_CallBack

[0000:00:00:00.853] BSP_AUDIO_OUT_TransferComplete_CallBack

[0000:00:00:00.863] BSP_AUDIO_OUT_HalfTransfer_CallBack

[0000:00:00:00.873] BSP_AUDIO_OUT_TransferComplete_CallBack

```

What can be the problem ?

This topic has been closed for replies.

17 replies

BRusl.1
BRusl.1Author
Associate II
May 5, 2023

BTW: with SAI_SLOT_NUMBER set to 2 speaker output no longer works (silence) but headphone is ok.

BRusl.1
BRusl.1Author
Associate II
May 5, 2023

I've hoped that stock example is something that should work and tested at factory with all outputs, sample rates, etc. but seems this is just buggy skeleton code

AScha.3
Super User
May 5, 2023

oh, its STM standard.... :)

If you feel a post has answered your question, please click on " Best Answer ".
BRusl.1
BRusl.1Author
Associate II
May 6, 2023

They are always using 4 slots - 2 for speaker, 2 for headphone, I think this is for having the same SAI config for OUTPUT_DEVICE_BOTH mode. Next I've found the BSP_AUDIO_IN_OUT_Init() which works at least for 4 slots. Thanks AScha for your help again !