AnsweredAssumed Answered

Audio on STM32F4

Question asked by D on May 25, 2012
Latest reply on May 30, 2012 by D
Hi guys !

Firstly - hello to everyone ! I have some questions. I am trying to make a project on STM32F407VG that would transfer data from microphone to the headphones through a filter. I am totally new to these topics so until now I was trying to turn on CS43L22 but I think I lack of some information. I would appriciate if you tell me just make a few tips how to work this out. This is what I have now and have no idea if this is right and what to do next :

#include "stm32f4xx_conf.h"
#include "stm32f4xx.h"
 
 
DAC_InitTypeDef DAC_InitStruct;
I2S_InitTypeDef I2S_InitStruct;
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitTypeDef GPIO_InitStructC;
uint8_t rxdata;
 
void main(void)
{
 
 
//RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
 
  GPIO_InitStruct.GPIO_Pin  = GPIO_Pin_10;
  GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStruct.GPIO_Speed = GPIO_Speed_25MHz;
  GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_PinAFConfig(GPIOB, GPIO_PinSource10,GPIO_AF_SPI2);
 
GPIO_Init(GPIOB,&GPIO_InitStruct);
 
 
 
  GPIO_InitStruct.GPIO_Pin  = GPIO_Pin_3;
  GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStruct.GPIO_Speed = GPIO_Speed_25MHz;
  GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_PinAFConfig(GPIOB, GPIO_PinSource3,GPIO_AF_SPI2);
 
GPIO_Init(GPIOC,&GPIO_InitStruct);
 
 
I2S_InitStruct.I2S_Mode =I2S_Mode_MasterRx;
I2S_InitStruct.I2S_DataFormat =I2S_DataFormat_16b;
I2S_InitStruct.I2S_MCLKOutput =I2S_MCLKOutput_Enable;
I2S_InitStruct.I2S_AudioFreq =I2S_AudioFreq_44k;
I2S_InitStruct.I2S_CPOL =I2S_CPOL_Low;
RCC_I2SCLKConfig(RCC_I2S2CLKSource_PLLI2S);
 
I2S_Init(SPI2,&I2S_InitStruct);
//I2S_FullDuplexConfig(I2S2ext,I2S_InitStruct);
I2S_Cmd(SPI2,ENABLE);
 
while(1){
  SPI_I2S_ReceiveData(SPI2);
}
 
}

And some questions : Do I need to turn on AF function of some pin i.e. I2S2_CK to enable this clock or is it just for scoping if it works through some pin ?


Thanks for any help,
I'll try to narrow down my problem in the discussion.

Outcomes