LPC1769 I2S receive in slave mode

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by attesaarela on Thu Jul 19 05:13:41 MST 2012
I'm trying to read data by I2S in slave mode on an LPC1769 LPCXPresso board. I'm trying to connect the I2S into the pins of the LPCXPresso target board containing the LPC1769 MCU. I'm trying pin 1 for ground, pin 8 for data (SDA), pin 38 for bit clock (SCK?) and pin 39 for left/right clock (LRCK) . When I begin waiting for the first data word with a busy loop polling on I2S_GetLevel, no data arrives and the MCU gets stuck in the busy loop.

The I2S source is a TI PCM4220 ADC evaluation board and the I2S left/right clock (LRCK on the ADC board) has a signal at 48.4 kHz and the bit clock (BCK on the ADC board) has a signal at 6.16 MHz. The SCKO clock from the ADC board which I also tried for clock input has a signal at 12.28 MHz. These were all measured with a Circuitmate, I don't know how accurate it is.

The data line should also be ok, but I didn't measure the data line because it shouldn't matter for whether the I2S interface detects an I2S signal or not.

So I'm not sure if I configured everything corrctly. Should I use the fractional rate divider as the clock source? (I2S_CLKSEL_FRDCLK) Do I need the 4 pin mode? What frequency should the bit clock signal have? Should I use about 6 MHz or about 12 MHz or something else for 48 kHz , 32-bit, stereo? Do I need to manually set RXBITRATE, or does I2S_Freq_Config do it? This is most probably a clock signal problem, because in master mode it doesn't get hung waiting for a sample.

The I2S receiving code is adapted from the i2s_test_4_wire example from NXP. The LED blinking code here is from
some random example on the net, it seems to work :

I2S_MODEConf_Type I2S_ClkConfig;
I2S_CFG_Type I2S_ConfigStruct;

PinCfg.Funcnum = 1;
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = 0;
PinCfg.Pinnum = 4;
PinCfg.Portnum = 0;
PinCfg.Pinnum = 5;
PinCfg.Pinnum = 6;


I2S_ConfigStruct.wordwidth = I2S_WORDWIDTH_32;
I2S_ConfigStruct.mono = I2S_STEREO;
I2S_ConfigStruct.stop = I2S_STOP_ENABLE;
I2S_ConfigStruct.reset = I2S_RESET_ENABLE;
I2S_ConfigStruct.mute = I2S_MUTE_DISABLE;
I2S_ConfigStruct.ws_sel = I2S_SLAVE_MODE;

I2S_FreqConfig(LPC_I2S, 48000, I2S_RX_MODE); //frequency and bit rate.. needed in slave mode ?

I2S_ClkConfig.clksel = I2S_CLKSEL_FRDCLK;  //correct mode according to p. 486 of lpc17xx user manual.
I2S_ClkConfig.mcena = I2S_MCLK_DISABLE;
I2S_ClkConfig.fpin = I2S_4PIN_DISABLE;


#define LED2_MASK (1L << 22)

LPC_PINCON->PINSEL0 &= (!0x00003000);

while(1) {
    LPC_GPIO0->FIOCLR = LED2_MASK;    //never gets here