cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f4 + ICS43432 I2S Digital Microphone

rukudias
Associate II
Posted on October 29, 2016 at 17:04

I am using stm32f4 dev kit for making that things work.

I use I2S_Mode_MasterRx for I2S module(SPI2). 0690X00000605STQAY.png For getting system_stm32f4xx.c i use STM32F4xx_Clock_Configuration_V1.1.0.xls please find my current config below 0690X00000605SdQAI.png

void SPI2_IRQHandler(void) {
// Receiving data
if(SPI_GetITStatus(SPI2, SPI_I2S_IT_RXNE) == SET) {
uint16_t data = SPI2->DR;
}
}
int main(void)
{
//RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);
while(RCC_GetFlagStatus(RCC_FLAG_PLLI2SRDY));
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
RCC_PLLI2SCmd(ENABLE);
//RCC_APB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
// GPIO
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_PinAFConfig(GPIOB,GPIO_PinSource12, GPIO_AF_SPI2); // WCLK
GPIO_PinAFConfig(GPIOB,GPIO_PinSource13, GPIO_AF_SPI2); // BCLK
GPIO_PinAFConfig(GPIOB,GPIO_PinSource15, GPIO_AF_SPI2); // SDATA
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_15; // WCLK-BCLK-SDATA
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = SPI2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init (&NVIC_InitStructure);
I2S_InitTypeDef I2S_InitStructure;
I2S_StructInit(&I2S_InitStructure);
SPI_I2S_DeInit(SPI2);
I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_48k;
I2S_InitStructure.I2S_Standard = I2S_Standard_Phillips;
I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Disable;
I2S_InitStructure.I2S_CPOL = I2S_CPOL_Low;
I2S_InitStructure.I2S_DataFormat = I2S_DataFormat_16b;
I2S_InitStructure.I2S_Mode = I2S_Mode_MasterRx;
I2S_Init(SPI2, &I2S_InitStructure);
/* Enable the Rx buffer not empty interrupt */
SPI_I2S_ITConfig (SPI2, SPI_I2S_IT_RXNE, ENABLE);
/* Enable the I2S2 */
I2S_Cmd(SPI2, ENABLE);
while(1);
}

But i got the following diagram it seems to me the i2s does not work well any ideas? 0690X00000605QEQAY.png
4 REPLIES 4
Posted on October 29, 2016 at 23:52

> it seems to me the i2s does not work

Why do you think so? The master receiver should provide the bit clock and frame/wordselect/LR clock, and according to that waveform you have both of them.

The data come from the transmitter, I can't judge whether they are OK - is LR grounded i.e. mic is attempting to output on left channel? Is this waveform taken at the powerup or later?

JW

rukudias
Associate II
Posted on October 30, 2016 at 19:09

according the picture above

- LR is grounded as a result we use ch 2

-for ch1 the data value is 0xffff or 0x0000 is it ok?

Posted on October 30, 2016 at 22:59

> LR is grounded as a result we use ch 2

From ICS43432 datasheet:

i.e. if LR is grounded, it's the *left* microphone i.e. data is output when WS is low (ch1). What we see in ch2 is a floating (hi-Z) line, capacitively coupled to the data clock, IMHO.

Now 0x0000 and 0xFFFF is suspicious, but that's why I asked, which portion of data do we see, whether it is after the powerup or later. The ICS43432 states a rather lengthy (in terms of clocks) startup during which the data are invalid, and then a gradual fade-in (unmute).

JW

rukudias
Associate II
Posted on October 31, 2016 at 15:50

I have added right micro and redone the test

also

- I2S_InitStructure.I2S_DataFormat = I2S_DataFormat_24b;(The output data word length is 24 bits/channel)

- The data word format is 2?s complement, MSB first for ICS43432 I2S Digital Microphone

-The SD trace should have a pulldown resistor to discharge the line during the time that all microphones on the bus have tri-stated their outputs. A 100 k? resistor is sufficient for this, as shown in Figure 10. If the SD line needs to be discharged faster than a 100 k? resistor can, a smaller resistor, such as 10 k?, can be used.

but nevertheless i see this result

time,                         ch,  value

1.156853416666667,1,0xFFEF0E

1.156863750000000,2,0x0002EF

1.156874083333333,1,0xFFFBA2

1.156884375000000,2,0x0007E3

1.156894708333333,1,0xFFF691

1.156905041666667,2,0x0006FC

1.156915375000000,1,0xFFF3C7

1.156925666666667,2,0x0003B9

1.156936000000000,1,0x7FF83B

1.156946333333333,2,0x000C46

1.156956666666667,1,0xFFF670

1.156967000000000,2,0x00060F

1.156977333333333,1,0xFFFDDD

1.156987625000000,2,0x00043C

1.156997958333333,1,0xFFFC44

1.157008291666667,2,0x0007FC

1.157018625000000,1,0xFFFF0E

1.157028916666667,2,0x0005E4

1.157039250000000,1,0x7FFF07

1.157049583333333,2,0x000618

1.157059916666667,1,0x000116

1.157070250000000,2,0x000202

1.157080541666667,1,0x0000C0

1.157090875000000,2,0x0006F8

1.157101208333333,1,0x00000F

1.157111500000000,2,0x8001FF

1.157121833333333,1,0x00017F

1.157132166666667,2,0x000223

1.157142500000000,1,0x000306

1.157152791666667,2,0x0003FB

1.157163125000000,1,0x0004C3

1.157173458333333,2,0x0001F9

1.157183791666667,1,0x0002E1

1.157194125000000,2,0x0003E1

1.157204416666667,1,0x0001A4

1.157214750000000,2,0x7FFF73

1.157225083333333,1,0x000780

1.157235416666667,2,0x0002F2

1.157245708333333,1,0x00045E

1.157256041666667,2,0x0004F7

1.157266375000000,1,0x000877

1.157276708333333,2,0xFFFFEF

1.157287041666667,1,0x000CDA

1.157297333333333,2,0x000407

1.157307666666667,1,0x00071E

1.157318000000000,2,0x0001E3

1.157328333333333,1,0x0003A1

1.157338625000000,2,0x00040F

1.157348958333333,1,0x0007EE

1.157359291666667,2,0x000666

1.157369625000000,1,0x0001C3

0690X00000605SeQAI.pngi see that there is some issue with the processing

like this one

1.157018625000000,1,0xFFFF0E

1.157039250000000,1,0x7FFF07

1.157276708333333,2,0xFFFFEF

for some reasons micro still sends data to SD pin