/ ADC end-of-conversion ISR // Here we take the ADC sample, add it to a running total <accumulator>, and // decrement our local decimation counter <int_dec>.When <int_dec> reaches // zero, we calculate the new value of the global variable <result>, // which stores the accumulated ADC result. // void ADC_isr (void) interrupt 15 { static unsigned int_dec=256;// integrate/decimate counter // we post a new result when // int_dec = 0 static long accumulator=0L;// heres where we integrate the // ADC samples ADCINT = 0;// clear ADC conversion complete // indicator accumulator += ADC0;// read ADC value and add to running // total int_dec--;// update decimation counter if (int_dec == 0) {// if zero, then decimate int_dec = 256;// reset counter result = accumulator >> 4;// Shift to perform the divide operation accumulator = 0L;// dump accumulator } } 我的问题是:int_dec 和 accumulator 这两个变量的赋值是不是应该放在中断服务程序的外面? 作者:不辣的皮特 2005-1-13 9:49:00 |