How to play audio clips over I2S ?(DA7212 codec)

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
7 posts / 0 new
Last post
manisrinvas
Offline
Last seen:1 year 4 months ago
Joined:2018-11-19 12:45
How to play audio clips over I2S ?(DA7212 codec)

Hi Team,

I want to play audio clips over I2S like short audio clips - Connected to device , Disconnected etc, so. I converted.wav file to C- code(Im using WAVtoC software to convert C-code)and stored in flash memory. Below I attached the .wav to c code file.

I'm usingDA7212 Codecto play these audio clips over I2S.

These Audio clips has 8k sampling rate, 16bit bits per sample. Total number of samples around 3500.

I tried with interrupt method to transmit data of 512bytes each, pls check below code

  1. Number of elements are defined 3500 samples
  2. Unsigned short PowerOndata[NUM_ELEMENTS] = {--------- }; contains the 3500 samples values ,
  3. uint16_t *firstarray=STEREO_AUD_DATA; // data is stored Stereo format
  4. unsigned short STEREO_AUD_DATA[2*NUM_ELEMENTS];

void ConncetAUD(){

int i=0;

// store data in stereo format

for(int i=0;i

STEREO_AUD_DATA[(i*2)] = PowerOndata[i]; //left

STEREO_AUD_DATA((我* 2)+ 1)= PowerOndata [i]; //right

}

firstarray=STEREO_AUD_DATA;

while(i < 15){

if(HAL_I2S_GetState(&CODEC_I2S) == HAL_I2S_STATE_READY){

HAL_I2SEx_TransmitReceive_IT(&CODEC_I2S,firstarray,rxBuffer, 512); // will get callback event here-HAL_I2SEx_TxRxCpltCallback

Display(("voice prompt :%d\n",*firstarray));

i++;

osDelay(200);

}

}

}

3. update data in call back function.

void HAL_I2SEx_TxRxCpltCallback(I2S_HandleTypeDef *hi2s){

firstarray += 512;

}

I'm sure that I configured codec registers properly, I can able to play music and all, which is connected to BT. I'm using stm32f4 series microcontroller, the DA7212 is connected to this controller.

Device:
bmcadam
Offline
Last seen:3 weeks 6 days ago
Staff
Joined:2015-09-16 16:25
下午,

下午,

Have attached a setup file of the Registers writes to do I2C to HP using "These Audio clips has 8k sampling rate, 16bit bits per sample."

Regards,

manisrinvas
Offline
Last seen:1 year 4 months ago
Joined:2018-11-19 12:45
thank you for replying,

thank you for replying,

Initial setup was similar to mine registers set up. I have tested with voice prompt like "POWER ON ", but it is not working.

which data you have tested? or you tested with tone generation?

bmcadam
Offline
Last seen:3 weeks 6 days ago
Staff
Joined:2015-09-16 16:25
It was tested with a Music

It was tested with a Music File.

manisrinvas
Offline
Last seen:1 year 4 months ago
Joined:2018-11-19 12:45
okay,

okay,
the music file was stored in sd card through i2s you are able to play. Is my understading is correct?

But I want to play the audio clips over i2s through array of samples which is stored in flash memory.

bmcadam
Offline
Last seen:3 weeks 6 days ago
Staff
Joined:2015-09-16 16:25
It sounds this is software

It sounds this is software related rather than the operation of the DA7212.

manisrinvas
Offline
Last seen:1 year 4 months ago
Joined:2018-11-19 12:45
yeah, it would be issue in

yeah, it would be issue in the firmware. let you know once i try