欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
單片機(jī)智能充電器程序
[打印本頁]
作者:
楚門的世界
時(shí)間:
2019-6-27 14:24
標(biāo)題:
單片機(jī)智能充電器程序
智能充電器的源程序
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit GATE = P2^0;
sbit BP = P2^1;
uint t_count,int0_count;
/* 定時(shí)器0中斷服務(wù)子程序 */
void timer0() interrupt 1 using 1
{
TR0 = 0; // 停止計(jì)數(shù)
TH0 = -5000/256; // 重設(shè)計(jì)數(shù)初值
TL0 = -5000%256;
t_count++;
if (t_count>600) // 第一次外部中斷0產(chǎn)生后3s
{
if (int0_count==1) // 還沒有出現(xiàn)第二次外部中斷0,則認(rèn)為充電完畢
{
GATE = 0; // 關(guān)閉充電電源
BP = 0; // 打開蜂鳴器報(bào)警
}
else // 否則即是充電出錯(cuò)
{
GATE = 1;
BP = 1;
}
ET0 = 0; // 關(guān)閉T0中斷
EX0 = 0; // 關(guān)閉外部中斷0
int0_count = 0;
t_count = 0;
}
else
TR0 = 1; // 啟動(dòng)T0計(jì)數(shù)
}
/* 外部中斷0服務(wù)子程序 */
void int0() interrupt 0 using 1
{
if (int0_count==0)
{
TH0 = -5000/256; // 5ms定時(shí)
TL0 = -5000%256;
TR0 = 1; // 啟動(dòng)定時(shí)/計(jì)數(shù)器0計(jì)數(shù)
t_count = 0; // 產(chǎn)生定時(shí)器0中斷的計(jì)數(shù)器清零
}
int0_count++;
}
/* 初始化 */
void init()
{
EA = 1; // 打開CPU中斷
PT0 = 1; // T0中斷設(shè)為高優(yōu)先級(jí)
TMOD = 0x01; // 模式1,T0為16位定時(shí)/計(jì)數(shù)器
ET0 = 1; // 打開T0中斷
IT0 = 1; // 外部中斷0設(shè)為邊沿觸發(fā)
EX0 = 1; // 打開外部中斷0
GATE = 1; // 光耦正常輸出電壓
BP = 1; // 關(guān)閉蜂鳴器
int0_count = 0; // 產(chǎn)生外部中斷0的計(jì)數(shù)器清零
}
void main()
{
/* 調(diào)用初始化函數(shù) */
init();
/* 無限循環(huán) */
while(1);
}
復(fù)制代碼
作者:
admin
時(shí)間:
2019-6-27 19:32
本帖需要重新編輯補(bǔ)全電路原理圖,源碼,詳細(xì)說明與圖片即可獲得100+黑幣(帖子下方有編輯按鈕)
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1