Module PWMLibrary.c Description This is a library for initialization of PWM and setting functions Notes Private definitions SERVO_CLOSE SERVO_OPEN PeriodInMS PWMTicksPerMS BitsPerNibble DutyCycleA DutyCycleB DutyCycleServo /*---------------------------- Module Functions ---------------------------*/ /* prototypes for private functions for this service.They should be functions relevant to the behavior of this service */ void InitPWM(void) //Enable clock to PWM module 0 //Enable clock to port b //Enable clock to port a //Select PWM clock as system clock/4 //Make sure PWM module is running //Disable PWM while initializing //Program generators //Set PWM period //Set initial duty cycle //Enable PWM outputs //Configure ports to be PWM outputs //Map PWM to necessary pins //Enable pins for digital I/O //Enable pins to be outputs //Enable pin for input //Set outputs low //Set up/down count mode void SetDCPWM(uint16_t DC, uint8_t Direction) //If direction is forward //Set pin hi //Invert duty cycle //Set duty cycle //else //Set pin lo //Set duty cycle void OpenServo(void) //Set servo open position duty cycle void CloseServo(void) //Set servo close position duty cycle