#include "N76E003.h"
#include "Common.h"
#include "Delay.h"
#include "SFR_Macro.h"
#include "Function_define.h"
#include "stdio.h"
#define uchar unsigned char
#define uint unsigned int
uint jici=0;pinlv=0;
void delay(uint xms);
void Timer0_ISR(void)interrupt 1
{
jici++;
TH0=61536/256;
TL0=61536%256;
if(jici==33)
{
TR0=TR1=0;
pinlv=TL1+TH1*256;
TL1=TH1=0;
jici=0;
TR0=TR1=1;
}
}
void dis(uint num)
{ clr_LOAD;
set_SFRPAGE;
PWM5L+=500;
clr_SFRPAGE;
set_LOAD;
set_PWMRUN;
}
void main()
{
Set_All_GPIO_Quasi_Mode;
PWM5_P03_OUTPUT_ENABLE;
PWM4_P01_OUTPUT_ENABLE;
PWM3_P00_OUTPUT_ENABLE;
set_T1M;
clr_PWMTYP;
clr_PWMMOD0;
clr_PWMMOD1;
PWM_CLOCK_DIV_8;
PWMPH = 0x07;
PWMPL = 0xCF;
set_SFRPAGE;
PWM5H = 0x03;
PWM5L = 0xe8;
PWM4H = 0x03;
PWM4L = 0xe8;
PWM3H = 0x00;
PWM3L = 0x00;
clr_SFRPAGE;
set_LOAD;
set_PWMRUN;
TMOD=0x51;
TH0=61536/256;
TL0=61536%256;
TR0=1;
ET0=1;
EA=1;
TH1=0;
TL1=0;
TR1=0;
while(1)
{
dis(pinlv);
}
}
是通过检测脉冲来调整单片机 PWM的输出 有哪里不对的地方请大神指出来
QAQ 萌新上路
|