找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1659|回复: 0
打印 上一主题 下一主题
收起左侧

利用定时计数器输出4路脉冲

[复制链接]
跳转到指定楼层
楼主
#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;}   
   
}
。。。


利用定时计数器输出4路脉冲.rar

48.64 KB, 下载次数: 9, 下载积分: 黑币 -5

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表