AnsweredAssumed Answered

EVAL_AUDIO Codec Configuration STM32F4 Discovery

Question asked by Palaima.Emmett on Jul 13, 2016
Hi, I am working with the STM32F4 discovery board and I'm trying to use the built in codec. I am trying to configure it to play audio from 2 alternating buffers I create. I have set up my callback function to start playing the next buffer once the previous buffer is finished. Currently for testing purposes I set all values in one buffer to 0 and all in the other to 32767, which creates a crude square wave, but I am not getting any audio out, can anyone see what I am missing?

I start audio playback in my main via:

#define MY_BUFSIZE 1024

static volatile uint8_t nextbuf;
static volatile uint16_t bufferNumber;
static int16_t buf0[MY_BUFSIZE];
static int16_t buf1[MY_BUFSIZE];

int main(void){



  compute_buffer(buf0, MY_BUFSIZE, 0);
  compute_buffer(buf1, MY_BUFSIZE, 1);

  Audio_MAL_Play((uint32_t)buf0, MY_BUFSIZE / 2);
 //EVAL_AUDIO_Play((uint16_t*)buf0, MY_BUFSIZE/2);



Here is my callback function:

void EVAL_AUDIO_TransferComplete_CallBack(uint32_t pBuffer, uint32_t Size)

    if(nextbuf == 0) { ;
        Audio_MAL_Play((uint32_t)buf0, MY_BUFSIZE);
        nextbuf = 1;
    } else {
        Audio_MAL_Play((uint32_t)buf1, MY_BUFSIZE);
        nextbuf = 0;

Here is how I fill the buffers:

void compute_buffer(int16_t *pbuf, int bufsize, uint16_t bufferNumber)
    int i;
    for(i = 0; i < bufsize / 2; i+=2) {
        pbuf[i] = bufferNumber * 32767;
        pbuf[i + 1] = bufferNumber * 32767;

Do I need to use the DAC instead of I2S, or is there something else I need to configure? I was having a hard time finding how the EVAL_AUDIO_TransferComplete_CallBack function is connected to the Audio_MAL_Play function. I also tried using EVAL_AUDIO_Play, with the same results.