初用新唐,写了一个PWM程序输出不成功,请高手指教
#include <W79E2051_4051.H>
#define uchar unsigned char
#define uint unsigned int
void sysinit(void);
void PWM(void);
uint PWM_Period=100;
uint pwm_duty;
uint counter ;
void main(void)
{
sysinit();
P35=1;
while(1)
{
P34=1;
P16=0;
PWM();
}
}
void sysinit(void)
{
P1M1=0x03; //P1.0 P1.1
P1=0xF3;
P3=0xa1;
PWMCON3=0x10; //
PWMCON1=0xD1;
EA=1;
}
void PWM(void)
{
PWMPL=PWM_Period;
PWMPH=PWM_Period>>8;
pwm_duty=50;
PWM0L=pwm_duty;
PWM0H=pwm_duty>>8;
} |