ADC interrupt

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADC interrupt

1,140 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Mallikarjuna on Mon Jun 06 06:34:59 MST 2016
Daer All


i want do adc with interrupt for that i did initialization mentioned below (void ADC_init(void) ); but it is not generating interrupt nor

not going to interrupt. please check initialization and let me know correct or not.?!

Thank you:-)
 

void ADC_Init (void) {
  LPC_SC->PCONP       |=  (1<<12);                  /* Enable power to ADC block */
  LPC_PINCON->PINSEL1 &= ~(1UL<<18);
  LPC_PINCON->PINSEL1 |=  (1UL<<18);        /* select AD2 pin */
  LPC_SC->PCLKSEL0  =     (0 << 24);           
  LPC_ADC->ADCR       =   (1 << 2)  |               /* select AD0.2 pin */
                                           (4 << 8)  |               /* ADC clock is 25MHz/4 */
           (5 << 16) |              /* Burst Bit */
           (1 << 21) |              /* enable ADC */
           (1 << 24) |              /*Start conversion now*/
           (1 << 27) ;              /*Start conversion on a falling edge*/

  LPC_ADC->ADINTEN = 0x00000004;
  NVIC_EnableIRQ(ADC_IRQn);
}



void ADC_IRQHandler(void)
{
uint32_t adGdr = 0,sTatus = 0,Dummy = 0;
sTatus = LPC_ADC->ADSTAT;
adGdr = LPC_ADC->ADGDR;
Dummy = LPC_ADC->ADDR2;
adGdr = ((adGdr >> 4) & ADC_VALUE_MAX);

}
Labels (1)
Tags (1)
0 Kudos
3 Replies

680 Views
rons
Contributor II

You are not clearing the pending state in ICPR0 register.

I suggest you see that your code works in polling mode first

0 Kudos

680 Views
rons
Contributor II

Two things I think you should change:

Assign the pin mode to "NONE" . Do not assign as "PULL-UP" or "PULL-DOWN"

Don't start the conversion until the NVIC is initialized for the ADC interrupt.

0 Kudos

680 Views
lpcware
NXP Employee
NXP Employee
bump
0 Kudos