標(biāo)題:
通過調(diào)節(jié)脈寬改變頻率
[打印本頁]
作者:
51hhcc
時間:
2017-4-7 11:47
標(biāo)題:
通過調(diào)節(jié)脈寬改變頻率
/*
占空比可以調(diào)整 pwm_h=20;
*/
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
sbit fangbo=P1^1;
uint count=0;
uchar pwm_h=20;
int main()
{
//定時器0 初始化 工作方式1 定時50ms
TMOD=0x01;
EA=1;
ET0=1;
TR0=1;
fangbo=0;
while(1)
{
}
}
void ftimer0() interrupt 1
{
TH0=(-1000)/256;
TL0=(-1000)%256;
count++;
if(count==100)
{
count=0;
fangbo=1;
}
else if(count==pwm_h)
{
fangbo=0;
}
}
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1