AnsweredAssumed Answered

ADC ISR in ADUC842 not getting triggered

Question asked by mayu.608 on Jul 31, 2012
Latest reply on Aug 9, 2012 by MMA

hello

 

I am using ADUC 842 controller....

 

I have written an ISR for ADC.

Inspite of giving an i/p of 1v to ADC channel , the ISR is not getting called.

pls go thru the following code.

 

#include <stdio.h>
#include <math.h>
#include <aduc842.h>
#pragma registerbank(2)
sfr16 ADCDATA16 = 0xD9;
float temp = 0.0;
float analog_value = 0.0;
float total = 0.0;
float int_part, frc_part;
float digitalvalue,decimal,integer;
int i;
float x;
void display(void);
unsigned long conv()
{
ADCCON1 = 0x0AC;
ADCCON2 = 0x010;
ADCCON3 = 0x015;

return(ADCDATA16 & 0xFFF);
}

void adc_int() interrupt 6 using 2

{ i = 1;
  }

void main()
{
PLLCON = 0x00;
EA = 1;

EADC = 1;
CCONV = 1;
//PADC = 1;
ES = 1;
T3CON = 0x86;
T3FD = 0x2D;

 

SCON = 0x50;

if (i == 1)
{
digitalvalue = conv();

analog_value = digitalvalue * 0.0006103515625;

if (analog_value >= 1.0186 && analog_value <= 1.1125)

{
temp = ((-42.542 * analog_value) + 93.319);
}

else if (analog_value >= 1.1125 && analog_value <= 1.1854)

{
temp = ((-41.192 * analog_value)+ 91.826);
}

else if (analog_value >= 1.1854 && analog_value <= 1.2855)

{
temp = ((-39.851 * analog_value)+ 90.23);
}

else if (analog_value >= 1.2855 && analog_value <= 1.3619)

{
temp = ((-39.317 * analog_value) + 89.546);
}

else if (analog_value >= 1.3619 && analog_value <= 1.4638)

{
temp = ((-39.159 * analog_value)+ 89.327);
}

else if (analog_value >= 1.4638 && analog_value <= 1.5403)
{
temp = ((-39.162 * analog_value)+ 89.331);

else if (analog_value >= 1.5403 && analog_value <= 1.6404)
{
temp = ((-39.931 * analog_value)+ 90.518);
}

else if (analog_value >= 1.6404 && analog_value <= 1.7377)
{
temp = ((-41.156 * analog_value)+ 92.534);

}
else if (analog_value >= 1.7377 && analog_value <= 1.8077)
{
temp = ((-42.899 * analog_value) + 95.562);
}

else if (analog_value >= 1.8077 && analog_value <= 1.8965)
{
temp = ((-45.036 * analog_value)+ 99.436);
}
else if (analog_value >= 1.8965 && analog_value <= 1.9590)
{
temp = ((-47.976 * analog_value)+ 105);
}

else if (analog_value >= 1.9590 && analog_value <= 2.0364)
{
temp = ((-51.662 * analog_value)+ 112.24);
}

else if (analog_value >= 2.0364 && analog_value <= 2.0898)
{
temp = ((-56.222 * analog_value)+ 121.51);
}

else if (analog_value >= 2.0898 && analog_value <= 2.1544)
{
temp = ((-61.935 * analog_value) + 133.47);
}
frc_part = modf (temp, &int_part);
decimal = frc_part * 100;
integer = int_part;

display();

}

}
/*
void display(void)
{
SBUF = integer;
while (TI == 0)
{
}
TI = 0;
}

 

 

 

 

 

 

 

Need help for the same...

 

Regards

Aditi

Outcomes