电机停转

  1. /*停止PWM输出*/
  2. void PWM_Stop(void)
  3. {
  4. timer_channel_output_state_config(TIMER0, TIMER_CH_0, TIMER_CCX_DISABLE);
  5. timer_channel_complementary_output_state_config(TIMER0, TIMER_CH_0, TIMER_CCX_DISABLE);
  6. timer_channel_output_state_config(TIMER0, TIMER_CH_1, TIMER_CCX_DISABLE);
  7. timer_channel_complementary_output_state_config(TIMER0, TIMER_CH_1, TIMER_CCX_DISABLE);
  8. timer_channel_output_state_config(TIMER0, TIMER_CH_2, TIMER_CCX_DISABLE);
  9. timer_channel_complementary_output_state_config(TIMER0, TIMER_CH_2, TIMER_CCX_DISABLE);
  10. }

电机调速

  1. void PWM_SetCompare1(uint16_t Compare)
  2. {
  3. timer_channel_output_pulse_value_config(TIMER0,TIMER_CH_0,Compare);
  4. timer_channel_output_pulse_value_config(TIMER0,TIMER_CH_1,Compare);
  5. timer_channel_output_pulse_value_config(TIMER0,TIMER_CH_2,Compare);
  6. }
  1. // if(gpio_input_bit_get(GPIOA, GPIO_PIN_0) != 0)
  2. // {
  3. // Delay_ms(20);
  4. // while (gpio_input_bit_get(GPIOA, GPIO_PIN_0) != 0);
  5. // Delay_ms(20);
  6. // //LED1_Turn();
  7. // //PWM_Stop();
  8. // if (speed < 1000)
  9. // {
  10. // speed += 100;
  11. // PWM_SetCompare1(speed);
  12. // }
  13. // else
  14. // {
  15. // speed = 0;
  16. // }
  17. // }