音影先锋亚洲天堂网|电影世界尽头的爱完整版播放|国产 熟女 91|高清无码免费观看欧美日韩|韩国一区二区三区黄色录像|美女亚洲加勒比在线|亚洲综合网 开心五月|7x成人在线入口|成人网站免费日韩毛片区|国产黄片?一级?二级?三级

登錄 免費(fèi)注冊(cè) 首頁(yè) | 行業(yè)黑名單 | 幫助
維庫(kù)電子市場(chǎng)網(wǎng)
技術(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ī)
請(qǐng)教一個(gè)變量賦值的問(wèn)題
/ 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
if判斷的執(zhí)行語(yǔ)句永遠(yuǎn)執(zhí)行不到了!
 
3樓: >>參與討論
不辣的皮特
可是有人說(shuō),因?yàn)槎x的是"static",所以
所以這兩條賦值語(yǔ)句在中斷服務(wù)程序里面
只會(huì)運(yùn)行一次

為什么?

4樓: >>參與討論
computer00
一個(gè)變量聲明為靜態(tài)變量時(shí),如果有初始化,則初始化只執(zhí)行一次
    放在外邊,就是全局變量。
    放在里邊,就是局部變量。
    一個(gè)變量聲明為靜態(tài)變量時(shí),如果有初始化,則初始化只執(zhí)行一次。
    這個(gè)在普通函數(shù)里是這樣規(guī)定的。
    在中斷服務(wù)函數(shù)里,是否是這樣,我就不清楚了。
    我想應(yīng)該是一樣的吧。

5樓: >>參與討論
不辣的皮特
謝謝
 
參與討論
昵稱:
討論內(nèi)容:
 
 
相關(guān)帖子
請(qǐng)問(wèn)版主及各位同行此電路如何編程(操作說(shuō)明2)
請(qǐng)版主及各位指點(diǎn)此電路如何編程?
關(guān)于SPI接口通訊的問(wèn)題
PC機(jī)的紅外通信?請(qǐng)指點(diǎn)
請(qǐng)教一個(gè)變量賦值的問(wèn)題
免費(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)