找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

帖子
查看: 2196|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

利用定時計數(shù)器輸出4路脈沖

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:505058 發(fā)表于 2020-4-12 17:38 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
#include <REG52.H>
#define uchar unsigned char
#define uint unsigned int
sbit LEVEL0=P1^0;
sbit LEVEL1=P1^2;
sbit LEVEL2=P1^4;
sbit LEVEL3=P1^6;  
uchar count0,count1,count2,count3;
/********占空比分別為5%,10%,20%,?50%*********/
void timer0isr(void) interrupt 1 using 1
{
TH0 = 0xD8;
TL0 = 0xF0;      
count0++;count1++;count2++;count3++;  
/**********占空比5%**********/
if(count0 == 5)
  LEVEL0 = 0;
if(count0==100)
{count0=0;LEVEL0=1;}
/**********占空比10%*********/
if(count1 == 10)
  LEVEL1 = 0;
if(count1==100)
{count1=0;LEVEL1=1;}
/*********占空比20%**********/
if(count2 == 20)
  LEVEL2 = 0;
if(count2==100)
{count2=0;LEVEL2=1;}
/********占空比50%**********/
if(count3 == 50)
  LEVEL3 = 0;
if(count3==100)
{count3=0;LEVEL3=1;}   
   
}
。。。


利用定時計數(shù)器輸出4路脈沖.rar

48.64 KB, 下載次數(shù): 9, 下載積分: 黑幣 -5

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

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

本版積分規(guī)則

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

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

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