|
#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;}
}
。。。
51hei截圖20200412173043.png (90.68 KB, 下載次數: 77)
下載附件
2020-4-12 17:37 上傳
51hei截圖20200412173732.png (22.2 KB, 下載次數: 64)
下載附件
2020-4-12 17:38 上傳
|
-
-
利用定時計數器輸出4路脈沖.rar
2020-4-12 17:34 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
48.64 KB, 下載次數: 9, 下載積分: 黑幣 -5
|