void wheel3(int pwm){ //REQUIRES: pwm_init() has been called // Takes a number from -255 to 255 where 0 is stopped and // 255 is full speed ahead //EFFECTS: Modifies the speed of wheel3 if (pwm == 0){ PWM_disable(&motors, PWM_5); PWM_disable(&motors, PWM_6); } else if (pwm > 0){ PWM_set_duty_cycle(&motors, PWM_5, pwm); PWM_enable(&motors, PWM_5); PWM_disable(&motors, PWM_6); } else { pwm = pwm * -1; PWM_set_duty_cycle(&motors, PWM_6, pwm); PWM_enable(&motors, PWM_6); PWM_disable(&motors, PWM_5); } return; }
// Set the PWM pulse width void PWM_width(uint16_t width) { PWM_disable(); // Timer counter match value for pulse width (sec 18.7.7) LPC_TMR16B0->MR0 = LPC_TMR16B0->MR1 - width; PWM_enable(); }