예제 #1
0
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;
}
예제 #2
0
파일: pwm.c 프로젝트: 0xdec/ECE395-Clarinet
// 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();
}