7 years, 5 months ago.

Audio freeze with STM32F4

I'm new to embedded programming and I'm currently working on a project with an STM32F469I-discovery board. I'm using eclipse with the ARM tool chain and the supplied drivers. I'm getting stuck on playing a binary audio file flashed into the chip at a specific address. I've very simply based my code on some of the example files, although very much cut down as I'm just trying to get it to work.

At the moment, the code works up to the point where it plays the buffer, but then it appears to get stuck. The buffer is playing in a loop (I've changed the size of the buffer to confirm this) and you can hear it, but that's all that happens.

What it should do is configure the system clock, fill the buffer, initialise the audio, then turn on the LED. It should then play the audio buffer, wait 1s, then turn off the LED. It plays the buffer in a loop (as it should as it's in circular mode) but then gets stuck and never turns off the LED. I've tried running it in normal mode but it simply plays the buffer once, and then gets stuck.

This leads me to think I've configured/filled the buffer incorrectly. However, I've noticed online that other people have had similar problems, and a patch was released for a different board for the BSP drivers (Disco F746NG). I've had a look through the audio source file and the only difference being an interrupt call. I've tried adding this but it hasn't worked. I've not so far found a solution for this.

  1. include "main.h"

static void SystemClock_Config(void);

  1. define AUDIO_FILE_ADDRESS 0x08010000
  2. define PLAY_HEADER 0x17569
  3. define PBSIZE 4096 uint16_t PlayBuff[PBSIZE];

int main(void) { BSP_LED_Init(LED1); HAL_Init(); /* Configure the system clock to 180 MHz */ SystemClock_Config(); Fill the buffer first time round for(int i=0; i <= PBSIZE; i++) { PlayBuff[i]=*((IO uint16_t *)(AUDIO_FILE_ADDRESS + PLAY_HEADER + i)); } BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_HEADPHONE ,50,AUDIO_FREQUENCY_44K );

BSP_LED_On(LED1);

BSP_AUDIO_OUT_Play(PlayBuff,PBSIZE);

HAL_Delay(1000);

BSP_LED_Off(LED1); }

Be the first to answer this question.