|
|||||||||||
| 技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測(cè)控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng) 驅(qū)動(dòng)編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機(jī) | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計(jì) | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe |
請(qǐng)教一個(gè)變量賦值的問(wèn)題 |
| 作者:不辣的皮特 欄目:單片機(jī) |
/ 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 } } 我的問(wèn)題是:int_dec 和 accumulator 這兩個(gè)變量的賦值是不是應(yīng)該放在中斷服務(wù)程序的外面?謝謝 |
| 2樓: | >>參與討論 |
| 作者: noley 于 2005/1/13 10:30:00 發(fā)布:
if判斷的執(zhí)行語(yǔ)句永遠(yuǎn)執(zhí)行不到了! |
|
| 3樓: | >>參與討論 |
| 作者: 不辣的皮特 于 2005/1/13 12:10:00 發(fā)布:
可是有人說(shuō),因?yàn)槎x的是"static",所以 所以這兩條賦值語(yǔ)句在中斷服務(wù)程序里面 只會(huì)運(yùn)行一次 為什么? |
|
| 4樓: | >>參與討論 |
| 作者: computer00 于 2005/1/13 12:32:00 發(fā)布:
一個(gè)變量聲明為靜態(tài)變量時(shí),如果有初始化,則初始化只執(zhí)行一次 放在外邊,就是全局變量。 放在里邊,就是局部變量。 一個(gè)變量聲明為靜態(tài)變量時(shí),如果有初始化,則初始化只執(zhí)行一次。 這個(gè)在普通函數(shù)里是這樣規(guī)定的。 在中斷服務(wù)函數(shù)里,是否是這樣,我就不清楚了。 我想應(yīng)該是一樣的吧。 |
|
| 5樓: | >>參與討論 |
| 作者: 不辣的皮特 于 2005/1/13 13:26:00 發(fā)布:
謝謝 |
|
|
|
| 免費(fèi)注冊(cè)為維庫(kù)電子開(kāi)發(fā)網(wǎng)會(huì)員,參與電子工程師社區(qū)討論,點(diǎn)此進(jìn)入 |
Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號(hào) |