Advertisement
tuthuytuoc

Untitled

Oct 14th, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. int main(void) {
  2.    
  3.     TM_PWM_TIM_t TIM2_Data;
  4.     /* Initialize system */
  5.     SystemInit();
  6.  
  7.     /* Set PWM to 1kHz frequency on timer TIM2 */
  8.     /* 1 kHz = 1ms = 1000us */
  9.     TM_PWM_InitTimer(TIM2, &TIM2_Data, 1000);
  10.     /* Initialize PWM on TIM2, Channel 1 and PinsPack 3 = PA15 */
  11.     TM_PWM_InitChannel(&TIM2_Data, TM_PWM_Channel_1, TM_PWM_PinsPack_3);
  12.     /* Initialize PWM on TIM2, Channel 2 and PinsPack 1 = PA1 */
  13.     TM_PWM_InitChannel(&TIM2_Data, TM_PWM_Channel_2, TM_PWM_PinsPack_1);
  14.  
  15. TM_PWM_SetChannelMicros(&TIM2_Data, TM_PWM_Channel_1, 900);
  16. TM_PWM_SetChannelMicros(&TIM2_Data, TM_PWM_Channel_2, 900);
  17.  
  18. while (1){
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement