电机停转
/*停止PWM输出*/void PWM_Stop(void){ timer_channel_output_state_config(TIMER0, TIMER_CH_0, TIMER_CCX_DISABLE); timer_channel_complementary_output_state_config(TIMER0, TIMER_CH_0, TIMER_CCX_DISABLE); timer_channel_output_state_config(TIMER0, TIMER_CH_1, TIMER_CCX_DISABLE); timer_channel_complementary_output_state_config(TIMER0, TIMER_CH_1, TIMER_CCX_DISABLE); timer_channel_output_state_config(TIMER0, TIMER_CH_2, TIMER_CCX_DISABLE); timer_channel_complementary_output_state_config(TIMER0, TIMER_CH_2, TIMER_CCX_DISABLE);}
电机调速
void PWM_SetCompare1(uint16_t Compare){ timer_channel_output_pulse_value_config(TIMER0,TIMER_CH_0,Compare); timer_channel_output_pulse_value_config(TIMER0,TIMER_CH_1,Compare); timer_channel_output_pulse_value_config(TIMER0,TIMER_CH_2,Compare);}
// if(gpio_input_bit_get(GPIOA, GPIO_PIN_0) != 0)// {// Delay_ms(20);// while (gpio_input_bit_get(GPIOA, GPIO_PIN_0) != 0);// Delay_ms(20);// //LED1_Turn();// //PWM_Stop();// if (speed < 1000)// {// speed += 100;// PWM_SetCompare1(speed);// }// else// {// speed = 0;// }// }