lpcware

Timer16_0 and ADC in burst mode

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by vdelabouere on Tue Dec 17 18:17:38 MST 2013
Hi,

I'm using Timer16_0 to generate a 1ms interrupt to do some tasks.

Now I want to use the ADC in burst mode for the first 4 ADC channels.
Here is the ADC_Init function :
void ADCInit( uint32_t ADC_Clk )
{
  uint32_t i;

  /* Disable Power down bit to the ADC block. */ 
  LPC_SYSCON->PDRUNCFG &= ~(0x1<<4);

  /* Enable AHB clock to the ADC. */
  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<13);

  for ( i = 0; i < 4; i++ )
  {
  ADCValue = 0x0;
  }
// IO configuration
LPC_IOCON->TDI_PIO0_11 &= ~0x9F; /*  ADC I/O config */
  LPC_IOCON->TDI_PIO0_11 |= 0x02;  /* ADC IN0 */
  LPC_IOCON->TMS_PIO0_12 &= ~0x9F;
  LPC_IOCON->TMS_PIO0_12 |= 0x02;  /* ADC IN1 */
  LPC_IOCON->TDO_PIO0_13 &= ~0x9F;
  LPC_IOCON->TDO_PIO0_13 |= 0x02;  /* ADC IN2 */
  LPC_IOCON->TRST_PIO0_14 &= ~0x9F;
  LPC_IOCON->TRST_PIO0_14 |= 0x02;  /* ADC IN3 */


  LPC_ADC->CR = ( 0x01 << 0 ) |  /* SEL=1,select channel 0~7 on ADC0 */
( ( SystemCoreClock / ADC_Clk - 1 ) << 8 ) |  /* CLKDIV = Fpclk / 1000000 - 1 */
( 0 << 16 ) | /* BURST = 0, no BURST, software controlled */
( 0 << 17 ) |  /* CLKS = 0, 11 clocks/10 bits */
( 0 << 24 ) |  /* START = 0 A/D conversion stops */
( 0 << 27 );/* EDGE = 0 (CAP/MAT singal falling,trigger A/D conversion) */

  // Enable the ADC ISR
  NVIC_EnableIRQ(ADC_IRQn);
  LPC_ADC->INTEN = 0x0F;/* Enable interrupts for the first 4 ADC Channels */
  return;
}

When I want to start the burst mode, I call this function :
void ADCBurstStart( void )
{
  if ( LPC_ADC->CR & (0x7<<24) )
  {
  LPC_ADC->CR &= ~(0x7<<24);
  }
  /* Read channels, 0 through 3.*/
  LPC_ADC->CR |= (0x0F);
  LPC_ADC->CR |= (0x1<<16);/* Set burst mode and start A/D convert */
  return;/* the ADC reading is done inside the
handler, return 0. */
}


It seems that as soon as I launch the ADC in burst mode, I don't have any more timer interrupts !
Any idea ?

Thanks

Vince


Outcomes