Content originally posted in LPCWare by rborozco on Fri Feb 04 15:32:19 MST 2011
I implemented this code for a LPC2148, but only AD0 is generating interruptions, AD1 does not.
Any idea?
#include <LPC214X.H>
#define AD0CR_INIT 0x002107DE //HW scan of valid channels with 3.33MHz
#define AD1CR_INIT 0x0021078F //HW scan of valid channels with 3.33MHz
void ADC_Init(void)
{
AD0INTEN=0x100;
AD1INTEN=0x100;
AD0CR = AD0CR_INIT;
AD1CR = AD1CR_INIT;
}
void IRQ_Init(void)
{
VICIntSelect=0x0;
/*ADC0*/
VICVectCntl0 = 0x20 | 0x12;
VICVectAddr0 = (unsigned)AD0_ISR;
VICIntEnable |= 0x00040000;
/*ADC1*/
VICVectCntl1 = 0x20 | 0x15;
VICVectAddr1 = (unsigned)AD1_ISR;
VICIntEnable |= 0x00200000;
}
/*********************Interrupt vector for AD0******************/
void AD0_ISR(void) __irq
{
unsigned val,chan;
val=AD0GDR;
chan=(val>>24)&0x07;
val=((val>>8) & 0x03FF);
ad0_event_counter++;
SMC_power_sequencer(chan,val);
AD0STAT&=~(1<<16);//Clears interruption
VICVectAddr=0x00000000;
}
/*********************Interrupt vector for AD1******************/
void AD1_ISR(void) __irq
{
unsigned val,chan;
val=AD1GDR;
chan=0x08|((val>>24)&0x07);
val=((val>>8) & 0x03FF);
ad1_event_counter++;
SMC_power_sequencer(chan,val);
AD1STAT&=~(1<<16);//Clears interruption
VICVectAddr=0x00000000;
}
Thanks
Roberto B