pwm可调用.txt

来自「数控直流电源和变频电源程序在c环境下编译」· 文本 代码 · 共 50 行

TXT
50
字号
#include <reg51.h>
#include <stdio.h>
#include <math.h>
#define unit unsigned int

sbit P1_0=P1^0;
int a=250,b=250,th0,tl0,th1,tl1;

void init()
{
 TMOD=0X11;
 TH0=th0;
 TL0=tl0;
 TH1=th1;
 TL1=tl1;
 }
void main()
{
 th0=(65536-a)/256;
 tl0=(65536-a)%256;
 th1=(65536-b)/256;
 tl1=(65536-b)%256;
 init();
 P1_0=1;
 EA=1;
 ET0=1;
 ET1=1;
 TR0=1;
 TR1=0;
 while(1);
  }
void timer0(void) interrupt 1
 {
     P1_0=~P1_0;
     TR1=1;
     TR0=0;
     TH0=th0;
     TL0=tl0;
   }

void timer1(void) interrupt 3
{
 P1_0=~P1_0;
 TR0=1;
 TR1=0;
 TH1=th1;
 TL1=tl1;
  }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?