找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

帖子
查看: 3010|回復(fù): 1
收起左側(cè)

利用定時(shí)器延時(shí)

[復(fù)制鏈接]
ID:73076 發(fā)表于 2015-2-11 20:56 | 顯示全部樓層 |閱讀模式
#include <reg52.h>
#define DELAY_TIME 120       //時(shí)間設(shè)置    秒 = DELAY_TIME * system_delay(系統(tǒng)時(shí)標(biāo)時(shí)間)
bit b_switch_delay = 0;
unsigned char u_tem = 0;

void switch_delay()
{
        if (system_delay)
        {
                system_delay = 0;                                //定時(shí)器系統(tǒng)時(shí)標(biāo)清0;
                if (u_temp >= DELAY_TIME)
                {
                        b_switch_delay = 1;                        //延時(shí)時(shí)間標(biāo)記
                }
                else
                u_temp++;
        }       
}
//復(fù)位延時(shí)清0
void rst_switch_delay()
{
        u_temp                         = 0;                                //臨時(shí)計(jì)數(shù)變量清0;
        b_switch_delay         = 0;                                //延時(shí)時(shí)間標(biāo)記清0
}

評分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的積分獎(jiǎng)勵(lì)!

查看全部評分

相關(guān)帖子

回復(fù)

使用道具 舉報(bào)

ID:1 發(fā)表于 2015-2-11 22:06 來自觸屏版 | 顯示全部樓層
注釋比較詳細(xì),謝謝分享
回復(fù)

使用道具 舉報(bào)

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表