下載本文檔
版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、這是程序,相信有多人有了,我可是研究了很一段時(shí)間,新手在成長(zhǎng)!呵呵/-/ defines wdt smclk interval for sensor measurementsdefine wdt_meas_setting (div_smclk_512)/ defines wdt aclk interval for delay between measurement cyclesdefine wdt_delay_setting (div_aclk_512)/ sensor settingsdefine num_sen 5 / defines number of sensors/ definiti
2、ons for use with the wdt settingsdefine div_aclk_32768 (wdt_adly_1000) /* aclk/32768 */define div_aclk_8192 (wdt_adly_250) /* aclk/8192 */define div_aclk_512 (wdt_adly_16) /* aclk/512 */define div_aclk_64 (wdt_adly_1_9) /* aclk/64 */define div_smclk_32768 (wdt_mdly_32) /* smclk/32768 */define div_sm
3、clk_8192 (wdt_mdly_8) /* smclk/8192 */define div_smclk_512 (wdt_mdly_0_5) /* smclk/512 */define div_smclk_64 (wdt_mdly_0_064) /* smclk/64 */ define hardware inputs/outputsdefine ca_out (0x80) / comparator output on p1.7define ca_ref (0x02) / comparator reference on p1.1define ta_clk (0x01) / timer_a
4、 clock input on p1.0define s_1 (0x04) / sensor 1 p1.2define s_2 (0x08) / sensor 2 p1.3define s_3 (0x10) / sensor 3 p1.4define s_4 (0x20) / sensor 4 p1.5define s_5 (0x40) / sensor 4 p1.6define ca_1 (p2ca4) / mux settings: ca+ vref at ca1define ca_2 (p2ca2) / mux settings: sensor 1 at ca2define ca_3 (
5、p2ca1+p2ca2) / mux settings: sensor 2 at ca2define ca_4 (p2ca3) / mux settings: sensor 3 at ca2define ca_5 (p2ca1+p2ca3) / mux settings: sensor 4 at ca2define ca_6 (p2ca2+p2ca3) / mux settings: sensor 4 at ca2define 1 (0x40) / p2.6define led2 (0x80) / p2.7/ global variables for sensingunsigned int b
6、ase_cntnum_sen;unsigned int meas_cntnum_sen;int delta_cntnum_sen;unsigned char key_pressnum_sen;const unsigned int key_lvl_s5=4000,40,40,90,100;const unsigned int key_lvl_w5=4000,40,40,90,100;char key_pressed, key_loc;int cycles;unsigned int ledcount = 4000;unsigned int ledtimer = 10;unsigned int sw
7、judge = 0;/ system routinesvoid measure_count(void); / measures each capacitive sensorvoid pulse_led(void); / led gradient routine (for demo only)/ main functionvoid main(void)volatile unsigned int i,j;wdtctl = wdtpw + wdthold; / stop watchdog timerbcsctl1 = calbc1_1mhz; / set dco to 1, 8, 12 or 16m
8、hzdcoctl = caldco_1mhz;bcsctl1 |= diva_0; / aclk/(0:1,1:2,2:4,3:8)bcsctl3 |= lfxt1s_2; / lfxt1 = vloie1 |= wdtie; / enable wdt interruptp1out = 0x00; / p1.x = 0p1dir = 0xfe; / p1.0 = taclk inputp1sel |= 0x81; / p1.0 = taclk input, p1.7 = caoutp2out = 0x00; /p2sel = 0x00; / no xtalp2dir |= led1+led2;
9、p2out |= led2;p2sel |= led1;capd = ca_ref; / disable input buffer for ca+ ref inputcactl2 = ca_1; / ca1 = ca+ vref_eint(); / enable interruptsmeasure_count(); / establish an initial baseline capacitancefor (i = 0; i if(meas_cnt>1000)swjudge+;for (i = 0; i base_cnt = meas_cnt;for(i=15; i>0; i-)
10、 / repeat and average base measurement measure_count();for (j = 0; j base_cntj = (meas_cntj+base_cntj)/2;/ main loop starts herewhile (1)key_pressed = 0; / assume no keys are pressedmeasure_count(); / measure all sensorsfor (i = 0; i delta_cnt = base_cnt - meas_cnt; / calculate delta: c_change/ handle baseline measurment for a base c decreaseif (delta_cnt key_lvl_w) / determine if each key is pressed per a preset thresholdkey_press = 1; / specific key pressedkey_pressed = 1; / any key pressedp2out = led2;while(ledtimer-)ledcount -= 5;if(ledcount key_lvl_s) / determine if each k
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025-2030年中國(guó)蓖麻種植行業(yè)運(yùn)行動(dòng)態(tài)及前景趨勢(shì)預(yù)測(cè)報(bào)告
- 2025-2030年中國(guó)舞臺(tái)燈光行業(yè)市場(chǎng)發(fā)展現(xiàn)狀與投資前景趨勢(shì)分析報(bào)告
- 2025年文藝巡回演出贊助商權(quán)益交換合同3篇
- 二零二五年度防雷設(shè)施安全評(píng)價(jià)與整改合同3篇
- 2025-2030年中國(guó)磚瓦市場(chǎng)競(jìng)爭(zhēng)狀況及投資趨勢(shì)分析報(bào)告
- 2025-2030年中國(guó)盤(pán)條(線(xiàn)材)市場(chǎng)規(guī)模分析及投資策略研究報(bào)告
- 2025-2030年中國(guó)電暖氣行業(yè)發(fā)展現(xiàn)狀及前景趨勢(shì)分析報(bào)告新版
- 2025-2030年中國(guó)特氟龍板材項(xiàng)目風(fēng)險(xiǎn)評(píng)估報(bào)告
- 2025-2030年中國(guó)熊果苷市場(chǎng)發(fā)展動(dòng)態(tài)及前景趨勢(shì)分析報(bào)告
- 2025-2030年中國(guó)海水養(yǎng)殖市場(chǎng)需求規(guī)模分析及前景趨勢(shì)預(yù)測(cè)報(bào)告
- 上海紐約大學(xué)自主招生面試試題綜合素質(zhì)答案技巧
- 辦公家具項(xiàng)目實(shí)施方案、供貨方案
- 2022年物流服務(wù)師職業(yè)技能競(jìng)賽理論題庫(kù)(含答案)
- ?;钒踩僮饕?guī)程
- 連鎖遺傳和遺傳作圖
- DB63∕T 1885-2020 青海省城鎮(zhèn)老舊小區(qū)綜合改造技術(shù)規(guī)程
- 高邊坡施工危險(xiǎn)源辨識(shí)及分析
- 中海地產(chǎn)設(shè)計(jì)管理程序
- 簡(jiǎn)譜視唱15942
- 《城鎮(zhèn)燃?xì)庠O(shè)施運(yùn)行、維護(hù)和搶修安全技術(shù)規(guī)程》(CJJ51-2006)
- 項(xiàng)目付款審核流程(visio流程圖)
評(píng)論
0/150
提交評(píng)論