ADC on LPC2134 vs. ADC on LPC2138
2006-02-06 by gaquaycalifornia
Hi,
Please help with the Adcs.
I having problem of reading conversion from ADC_1.
LPC2134/6/8 have two ADCs and 16 pins to connect to.
I wrote the following code. and it runs fine in the evaluation board
LPC2138, but not the target board LPC2134.
Here is what I did.
Initialize ADC0
Initialize ADC1
Both has interrupt vectors assigned to.
#define configure_adc_0 0x01215F00
#define configure_adc_1 0x01215F00
void adc_0_initialize (int * p, int lastchannel)
{
index_0 = 0;
memcpy(&x[0], p,32);
lastchannel_adc_0 = lastchannel;
VICVectAddr3 = (unsigned long)adc0_irq;
VICVectCntl3 = 0x32;
VICIntEnable |= VIC_BIT(VIC_ADC_0);
AD0CR = configure_adc_0 | Find_Next_Channel(lastchannel,0) ;
}
void adc_1_initialize (int * p, int lastchannel)
{
index_1 = 0;
memcpy(&y[0], p,32);
lastchannel_adc_1 = lastchannel;
VICVectAddr10 = (unsigned long)adc1_irq;
VICVectCntl10 = 0x35;
VICIntEnable |= VIC_BIT(VIC_ADC_1);
AD1CR = configure_adc_1 | Find_Next_Channel(lastchannel,1) ;
}
// to start both ADCs
void StartAdcs(void){
ADGSR = 0x01010000;
}
// isr of adc0
void adc0_irq (void) __irq
{
int chan, tmp;
unsigned short val;
tmp = AD0DR;
chan = ((tmp >> 24)& 0x07);
val = (unsigned short)((tmp >> 6 )& 0x3FF);
result_0[index_0][chan] = val;
index_0 = IncrementInindex(index_0,chan,0);
AD0CR = configure_adc_0 | Find_Next_Channel(chan,0) ;
VICVectAddr = 0;
}
// isr of adc1
void adc1_irq (void) __irq
{
int chan, tmp;
unsigned short val;
tmp = AD1DR;
chan = ((tmp >> 24)& 0x07);
val = (unsigned short)((tmp >> 6 )& 0x3FF);
result_1[index_1][chan] = val;
index_1 = IncrementInindex(index_1,chan,1);
AD1CR = configure_adc_1 | Find_Next_Channel(chan,1) ;
VICVectAddr = 0;
}
On the evaluation board which has LPC2138 it runs fine, both
interrupt got triggered.
When move this code onto the target with a LPC2134, only adc0 gets
triggerd.
Please take a look and help me with any ideas
thanks