#include <reg51.h>
sbit PWM0 = P2^0 ;
sbit PWM1 = P2^1 ;
unsigned char CYCLE; //定义周期 该数字X基准定时时间 如果是10 则周期是10 x 0.01ms
unsigned char PWM0_ON ;//定义高电平时间
unsigned char PWM1_ON ;//定义高电平时间
void delay(unsigned int cnt) //延时时间为cnt *1ms
{
//while(--cnt);
int x,y;
for(x=cnt;x>0;x--)
for(y=110;y>0;y--);
}
void Time0_Init()
{
TMOD |=0x01;//定时器设置 0.01ms in 12M crystal
TH0=(65536-10)/256;
TL0=(65536-10)%256;//定时0.01mS
IE= 0x82; //打开中断
TR0=1;
}
void Pre_Init()
{
CYCLE = 100;// 时间可以调整
}
main()
{
Time0_Init();
Pre_Init();
while(1)
{
PWM0_ON=40;
PWM1_ON=40;
}
}
/********************************/
/* 定时中断 */
/********************************/
void tim(void) interrupt 1 using 1
{
static unsigned char count; //
TH0=(65536-10)/256;
TL0=(65536-10)%256;//定时0.01mS
if (count==PWM0_ON)
{
PWM0 = 0; //
}
if (count==PWM1_ON)
{
PWM1 = 0; //
}
count++;
if(count == CYCLE)
{
count=0;
PWM0 = 1;
PWM1 = 1;
}
}
PWM.rar_89c52rc 模拟pwm_89c52rc产生pwm_STC 98C52有PWM_STC89C52RC PWM_
版权申诉
183 浏览量
2022-09-22
20:22:16
上传
评论
收藏 676B RAR 举报
刘良运
- 粉丝: 67
- 资源: 1万+
最新资源
- 6_Advertising-gd_LearningRate.ipynb
- BrushNet电商公司和摄影公司都在用的AI工作流
- 12_base.apk
- 520马上到了两款动态爱心表白HTML代码(附源码)李峋同款爱心,快送给你爱的她或(他)吧12 情侣纪念日代码.zip
- 电子设计竞赛的单相不间断电源设计
- cutcamera1715961370938.png
- 基于MATLAB的图像处理课程设计报告.doc
- tensorflow-gpu-2.6.0-cp38-cp38-manylinux2010-x86-64.whl
- mmexport1715960553858.png
- tensorflow-gpu-2.6.0-cp37-cp37m-manylinux2010-x86-64.whl
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈