Timer16_0 and ADC in burst mode

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Timer16_0 and ADC in burst mode

1,042 次查看
lpcware
NXP Employee
NXP Employee
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


标签 (1)
0 项奖励
回复
3 回复数

1,015 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Wed Dec 18 06:52:06 MST 2013
Without seeing your code, especially timer ISR and ADC ISR it's difficult to guess.
Is your timer interrupt still triggered? Did you change interrupt priorities?

Would be useful if you reduce your project to the basic problem and export / post it...
0 项奖励
回复

1,015 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by vdelabouere on Wed Dec 18 06:16:43 MST 2013
I stop the burst mode inside the timer ISR and restart it after in the main loop if needed.
0 项奖励
回复

1,015 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue Dec 17 18:48:30 MST 2013
How do you stop burst mode?
0 项奖励
回复