AnsweredAssumed Answered

Struggling with Audio on STM32F469I-Discovery

Question asked by Charlie Blackwall on Jun 23, 2017

   Hi, I'm quite new to the STM32F4 and am currently trying very simply to play audio from a binary file flashed into memory.

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. The transfer interrupt callbacks never execute, and hence the buffer does not refil and the full sample is never played.

I've tried using an external interupt to refil the buffer, but when I try this, it gets stuck. I've also tried to debug it by turning on LEDs, but this has confirmed that effectively it gets stuck shortly after playing the sample. The infinite while loop never executes, and the transfer interrupts never execute.

   My question is - why is it getting stuck and why are the interrupts not being triggered?

Any help would be greatly appreciated!


#include "main.h"
static void SystemClock_Config(void);
#define AUDIO_FILE_ADDRESS   0x08010000
#define PLAY_HEADER          0x2C
#define PBSIZE               4096
uint16_t                      PlayBuff[PBSIZE];
int OFFSET = 0;
int TransferState = 0;
int CycleCount1 = 1;
int CycleCount2 = 1;

main(void){  HAL_Init(); 
/* Configure the system clock to 180 MHz */ 
// Fill the buffer first time round  
for(int i=0; i <= PBSIZE; i++)
     {PlayBuff[i]=*((__IO uint16_t *)(AUDIO_FILE_ADDRESS + PLAY_HEADER + i));
(2,50,AUDIO_FREQUENCY_16K );  
           // refill the first part of the buffer
           OFFSET = CycleCount1*PBSIZE;
           for(int i=0; i <= PBSIZE/2; i++){
                  PlayBuff[i]=*((__IO uint16_t *)(AUDIO_FILE_ADDRESS + PLAY_HEADER + OFFSET));
                }           CycleCount1++;        }
           // refill the second part of the buffer
           OFFSET = CycleCount2*PBSIZE+PBSIZE;
           for(int i=PBSIZE/2; i <= PBSIZE; i++){
                 PlayBuff[i]=*((__IO uint16_t *)(AUDIO_FILE_ADDRESS + PLAY_HEADER + OFFSET));

void BSP_AUDIO_OUT_TransferComplete_CallBack(void){

void BSP_AUDIO_OUT_HalfTransfer_CallBack(void){