electronicsLearner77
- Jul 2, 2015
- 306
- Joined
- Jul 2, 2015
- Messages
- 306
I have configured the adc program in the following manner automatic conversion and interrupt based and i find that the interrupt is happening very frequently and i do not want at that rate. so i planned to use the following method only when i want the data i will enable the interrupts and in the rest of the program the interrupts will be OFF. Is it correct?
unsigned int localadc,adcdataavailable, global_adc;
int main(void)
{
adcinit();
while(1)
{
enableadcinterrupts();
if(adcdataavailable == TRUE)
{
localadc = global_adc;
adcdataavailable = FALSE;
}
disableadcinterrupts();
/*
remaining part of the program;
*/
}
}
interrupt adcinterrupt(void)
{
adcdataavailable = TRUE;
global_adc = ADCBUFF;
}
unsigned int localadc,adcdataavailable, global_adc;
int main(void)
{
adcinit();
while(1)
{
enableadcinterrupts();
if(adcdataavailable == TRUE)
{
localadc = global_adc;
adcdataavailable = FALSE;
}
disableadcinterrupts();
/*
remaining part of the program;
*/
}
}
interrupt adcinterrupt(void)
{
adcdataavailable = TRUE;
global_adc = ADCBUFF;
}