Advertisement
rsfutch77

Convert duty to pulse time

Apr 24th, 2017
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.30 KB | None | 0 0
  1. float frequency = 25000;
  2.    
  3. TM_PWM_InitTimer(TIM2, &TIM2_Data, frequency);
  4.    
  5. TM_PWM_InitChannel(&TIM2_Data, TM_PWM_Channel_1, TM_PWM_PinsPack_1);
  6.    
  7. double duty = 50.0;
  8. int pulseHigh = (1.0/frequency)*(duty/100.0)*1000000.0;
  9. TM_PWM_SetChannelMicros(&TIM2_Data, TM_PWM_Channel_1, pulsehigh);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement