找回密码
 注册

QQ登录

只需一步,快速开始

搜索

用51单片机定时计数器产生高低电平脉宽不相等的方波(C语言程序)

[复制链接]
coolice 发表于 2020-2-10 15:18:59 | 显示全部楼层 |阅读模式
仿真电路图:
105232s5iiyi44g84z4i88.png
仿真结果:
105303v8f9odod6o3k67f7.png
C语言程序代码:
  1. #include<reg51.h>
  2. sbit OSC = P2^0;

  3. main()
  4. {
  5.         TMOD=0x01;        
  6.     TH0=0x3C;  
  7.     TL0=0xB0;        
  8.     EA=1;             //?????
  9.     TR0=1;              //??T0???
  10.     ET0=1;             //??????0??
  11.     while(1);
  12. }

  13. void ET0_ISR(void) interrupt 1           //????
  14. {  
  15.         unsigned int i;
  16.    TH0=0x3C;  
  17.    TL0=0xB0;
  18.    i++;
  19.    if(i == 1)
  20.         {                          
  21.             OSC = 0;    //36us???????,????
  22.         }
  23.     else if (i == 3)                    
  24.         {
  25.             OSC = 1;   //360us???????,????
  26.                 i=0;           //????
  27.         }                        
  28. }

复制代码

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

本版积分规则

QQ|手机版|小黑屋|ELEOK |网站地图

GMT+8, 2024-3-28 20:51

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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