Advertisement
sandro1234

Untitled

Sep 6th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1.         dev_tim_t tim;
  2.  
  3.         tim.pwm.channel = 1;
  4.         tim.pwm.polarity = 0;
  5.         tim.pwm.remap = 0;
  6.  
  7.         // timer freq = 10 khz, pwm period = 1 sec, pwm pulse = 0.1 sec
  8.         dev_tim_pwm_init_mms(&tim, 1, 1000000, 16000, 1600);
  9.    
  10.         // pwm pulse = 0.3 sec
  11.     //  dev_tim_pwm_set_pulse_1k(&tim, 75);
  12.         int d = -90;
  13.         while(1)
  14.         {
  15.        
  16.                 dev_tim_pwm_set_pulse(&tim, 1600 + 2000 * d / (180));
  17.                 d++;
  18.                 TIMER_WAIT(100);
  19.             if(d==90)d=-90;
  20.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement