# ADC is not working properly in ADuC7021

I’m working on  ADuC 7021 microcontroller. But now I’m stucked with ADC reading. While reading the ADC channel directly it gives the correct count. But if I’m trying to read the ADC count on the timer ISR, some error occurred. Timer 0 (400ms)and timer 1 (50ms)are enabled. But by giving some delay (delay count 1500)on the ADC reading routine, exact value have been obtained. Here what may be the issue?

Also the temperature obtained by means of the internal temperature is also wrong. Say, for 30c it gives 130c.

Here is the routine.

unsigned short usGetADCChannel(unsigned char ucChannel)

{

IRQEN &= ~RTOS_TIMER_BIT;

IRQEN &= ~GP_TIMER_BIT;

REFCON = 0x01;

vDelay(1600);

__nop();

__nop();

__nop();

__nop();

__nop();

__nop();

__nop();

__nop();

while((ADCSTA & EOC) == 0);