lpcware

GIMA, I2S, Timer not counting correctly

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by ArriaLive on Mon Dec 08 11:08:45 MST 2014
I have spent many hours trying to debug this, but perhaps I am missing something.

I have configured I2S1 on the LPC4330 to follow the audio clock generating a wordclock of 48kHz.  This is verified with an oscilloscope.  But the specific rate coming off the I2S port is not the issue.  I am trying to count the number of words transferred based on the wordclock (I am using DMA to actually move the samples).  According to the documentation, I should be able to connect the I2S1_RX_WS signal to TIMER2 routing the signal through the GIMA.  When I do that, I should have something like this:

BASE_AUDIO_CLK -> I2S1 -> I2S1_RS_WS -> GIMA -> TIMER2 (see attached image).

This all seems to work except that the counting is incorrect.  In one case, I am trying to count 19200 samples, which should result in an interrupt from the TIMER at 2.5Hz (The GIMA divides by 128, and the TIMER is configured to count to 150, then interrupt).  However, the interrupt occurs about every 2.34Hz, after the I2S1 has only transferred about 18400 samples.

I2S1 is transferring correctly and has been verified.  Using DMA, I have verified the counts.  When TIMER2 interrupts, the TC is exactly 19200, even though I2S has only clocked out about 18400 samples.  So, somewhere in the GIMA or TIMER2, the timer is overcounting about 1 in every 16 clocks.

Can anyone tell me why that is?

Thanks,

Outcomes