中文字幕无码不卡一区二区三区_少妇被又大又粗又爽毛片久久黑人_91精品国产在热久久无毒不卡_久久久久久亚洲综合网站

技術(shù)熱線: 4007-888-234
設(shè)計(jì)開發(fā)

專注差異化嵌入式產(chǎn)品解決方案 給智能產(chǎn)品定制注入靈魂給予生命

開發(fā)工具

提供開發(fā)工具、應(yīng)用測(cè)試 完善的開發(fā)代碼案例庫分享

技術(shù)支持

從全面的產(chǎn)品導(dǎo)入到強(qiáng)大技術(shù)支援服務(wù) 全程貼心伴隨服務(wù),創(chuàng)造無限潛能!

新品推廣

提供新的芯片及解決方案,提升客戶產(chǎn)品競(jìng)爭(zhēng)力

新聞中心

提供最新的單片機(jī)資訊,行業(yè)消息以及公司新聞動(dòng)態(tài)

PICC實(shí)現(xiàn)秒、分、小時(shí)時(shí)鐘程序

更新時(shí)間: 2019-03-26
閱讀量:2070

//******************************************************************************* //程 序 名:高精度時(shí)鐘 //設(shè) 計(jì) 者:石魚WLEEN //設(shè)計(jì)說明:設(shè)置TMR0預(yù)分頻系數(shù)為16,一次計(jì)數(shù)中斷溢出時(shí)間為4096us(0x1000) // 每次TMR0中斷服務(wù)中對(duì)時(shí)間累計(jì)變量microsecond加上4096 // 程序主循環(huán)中不停地查詢變量microsecond,看是否超過50ms,如果時(shí)間超過 // 50ms,microsecond=microsecond-50000,同時(shí)50ms計(jì)數(shù)器ms501 // 基于50ms計(jì)數(shù)器的累加值,更新秒,分和小時(shí)值 // 雖然每一個(gè)50ms的變化時(shí)間略有偏差,但所有偏差值都保留在microsecond // ,并得到累計(jì)修正,所以長(zhǎng)時(shí)間跨度計(jì)時(shí)精確 //******************************************************************************* #include

//*******************//variable define//**********************************

long int microsecond; //microsecond accumulative unit int ms50; //50ms counter int second; //second counter int minute; //minute counter int hour; //hour counter

main() {

//*******************//initialize//************************************** T0CS=0; //timer0 work at timer mode T0IF=0; //clear timer0 flag PSA=0; PS2=1; PS1=0; PS0=0; //psa=0,ps2:ps0=100,1:16 prescale value T0IE=1; //timer0 overflow interrupt enable GIE=1; // global interrupt enable

//*******************//main loop//************************************** while(1) { CLRWDT(); //clear the watchdog T0IE=0; //temporarily forbid the timer0 to interrupt //to keep the value of microsecond

microsecond-=50000; if(microsecond>=50000) //deal with microsecond>=50000 { ms50=+1; //50ms counter increase 1 if(ms50!=20) T0IE=1; //the time is not one second, resume t0ie ms50=0; //the time is one second,clear ms50 second++; //second counter if(second!=60) T0IE=1; //the time is not one minute, resume t0ie second=0; //the time is one minute,clear second minute++; //minute counter if(minute!=60) T0IE=1; //the time is not one hour, resume t0ie minute=0; //the time is one hour,clear minute hour++; //hour counter if(hour!=24) T0IE=1; //the time is not 24h, resume t0ie hour=0; //the time is 24 hour,clear hour } else microsecond+=50000; T0IE=1; //resume t0ie } }

void interrupt timer(void) { microsecond+=4096; }

 



沙河市| 体育| 安西县| 阜阳市| 遂昌县| 定陶县| 诏安县| 内江市| 内江市| 郓城县| 抚宁县| 大悟县| 台北县| 沭阳县| 湘阴县| 陆良县| 咸阳市| 承德市| 滦南县| 思南县| 论坛| 隆德县| 通州区| 连江县| 广水市| 共和县| 醴陵市| 孙吴县| 克拉玛依市| 新蔡县| 安丘市| 汝阳县| 阿拉善右旗| 武夷山市| 遵义县| 武义县| 黔西县| 巴彦县| 渝北区| 剑川县| 鹿泉市|