用如下代码软件仿真,A0口不输出10K的PWM波,大哥看看哪里不对? 试了很多了,PWM不工作。 void main (void) { // Set internal RC clock RCCR = RCCRH0; SICSR = RCCRL0; AVDTHCR = 0x23; //set the internal RC oscillator Prescaler to 4MHz. // Set input/output pins: PADDR = 0x3F; //PORT A0/3/5 as output, A1/2/4 as input. PAOR = 0x3F; //PORT A0 as Pull-pull drive FET, A3(Reset)/A5(Drive LED) as Open Drain, A1/2/4 as floating for ADC. PADR = 0x0A; //Clear all output, A5 light LED. A3 configed 1. //Set the PWM Frequency and Duty Cycle ATRH = 0x0E; ATRL = 0x70; // Setup Auto Reload value for Fpwm = 10 KHz DCR0H = 0x0F; // PWM0 - Setup 50% duty cycle DCR0L = 0x38; ATCSR = 0x10; PWMCR = 0x01; // Enable PWM Outputs } |