Hi Andy,
Thx a lot. I am able to read the registers now. I have another problem now. I am not getting interrupts.
I have set up the i2s as a master receiver operating at a very low data rate (375 bits/sec). I verified the clock and ws signals using a scope.
I can see the rx FIFO level increase and cross the threshold (4) but no interrupt !!
I am pasting the code below. Once the i2s port is setup, the code polls the status reg in a loop for about 2 seconds before exiting.
extern "C" void I2S_IRQHandler(void);
volatile unsigned int i2sIntCnt = 0;
void I2S_IRQHandler(void)
{
NVIC_DisableIRQ(I2S_IRQn);
i2sIntCnt ++;
}
LocalFileSystem local("local");
FILE *fp;
int main()
{
unsigned int regVal;
fp = fopen("/local/i2s.dat", "w");
if (fp == NULL)
return 1;
fprintf(fp, "\n i2s interface test .... \n");
fprintf(fp, "\n PCONP<0x%x> \n", (LPC_SC->PCONP));
LPC_SC->PCONP |= (1UL << 27);
fprintf(fp, "\n PCONP<0x%x> \n", (LPC_SC->PCONP));
/*
* Pins: Select I2S pins and their modes in PINSEL0 to PINSEL4 and
* PINMODE0 to PINMODE4 (see Section 8.5).
*/
// CCLK / 4 (the default)
LPC_SC->PCLKSEL1 &= ~(3UL << 22); // 96 Mhz / 8 -> 12 Mhz
LPC_SC->PCLKSEL1 |= 3UL << 22;
fprintf(fp, "\n LPC_PINCON @ <0x%x> is <0x%x> \n",
&(LPC_PINCON->PINSEL0), LPC_PINCON->PINSEL0);
LPC_PINCON->PINSEL0 = 0x1550;
fprintf(fp, "\n LPC_PINCON @ <0x%x> is <0x%x> \n",
&(LPC_PINCON->PINSEL0), LPC_PINCON->PINSEL0);
LPC_I2S->I2SRXRATE = 0x01fa; // X is 1 and Y is 250 // 0x1096; // 0x0106; // 0x40bb; // X is 1 and Y is 3
LPC_I2S->I2SRXBITRATE = 63; // MCLK / 64 ->> Bit clock is 375
LPC_I2S->I2SRXMODE = 0;
LPC_I2S->I2SDAI = 0x1cc;
wait_ms(100);
LPC_I2S->I2SDAI = 0x1c4;
LPC_I2S->I2SIRQ = 0x1 | (4<<8);
NVIC_EnableIRQ(I2S_IRQn);
// Loop
int idx;
for (idx=0;idx<20;idx++)
{
wait_ms(100);
fprintf(fp, "\n Int-Cnt <%u> \n", i2sIntCnt);
fprintf(fp, "\n I2SSTATE @ <0x%x> is <0x%x> \n", &(LPC_I2S->I2SSTATE), LPC_I2S->I2SSTATE);
}
NVIC_DisableIRQ(I2S_IRQn);
fclose(fp);
}
I am able to read all other registers but not the i2s. I am wondering if the i2s module is disabled on my embed.
regVal = *((unsigned int *)(0x400a8034)); // Does not work. Looks like it causes an exception.
fprintf(fp, "\n regVal <0x%x> \n", regVal);
Need help ...