开启影子功能后,代码修改如下,我这边测试成功,你试试
void Stop_PWM(void)
{
timer_channel_output_pulse_value_config(TIMER0,TIMER_CH_0,0);
timer_channel_output_pulse_value_config(TIMER0,TIMER_CH_1,0);
timer_disable(TIMER0);
}
int main(void)
{
int cnt;
systick_config();
RCU_GPIO_Config();
Timer0_PWM_Init();
while(1)
{
timer_enable(TIMER0);
for(cnt=0;cnt<500;cnt++)
{
timer_channel_output_pulse_value_config(TIMER0,TIMER_CH_1,cnt);
delay_1ms(2);
}
Stop_PWM();
delay_1ms(1000);
}
} |