ADC interrupt code
2006-04-30 by sherifkamelzaki
Hi how are u all please i need some help here
my code uses the ADC to enter the interrupt it doesn't work
#include <targets/LPC213x.h>
static int timer0Count, timer1Count;
void init_ADC(void)
{
PINSEL0 |= 0x00000300; // select pin0.4 as AD pin AD0.6
PCONP |= 0x00001000; // enable the power to ADC.0
AD0CR = 0x00214040; // configure the AD & run at 88Khz clk at
CLK_DIV = 40
}
int ADC_Data(void)
{
int data_sample ;
int channel ; // we work on channel 6 , AD0.6
int value;
value = AD0DR;
channel = ((value >> 24 ) & 0x00000007);
if (channel == 6)
{
data_sample = ((value >> 6 ) & 0x000003ff);
return data_sample ;
}
}
static void timer0ISR(void) __attribute__ ((interrupt ("IRQ")));
static void
timer0ISR(void)
{
if (++timer0Count % 2)
VICVectAddr = 0;
}
int
main(void)
{
init_ADC();
VICIntSelect &= ~0x00040000;
VICIntEnable = 0x00040000;
VICVectCntl0 = 0x32;
VICVectAddr0 = (unsigned int)timer0ISR;
__ARMLIB_enableIRQ();
while (timer0Count < 5);
return 0;
}
thanks