PWM Psedocode
PWM Psedocode
// initializing PWM
Wait till the Ports B,C,D and E are ready i.e the clock is active
Wait till the PWM modules are ready i.e the clock is active
Set PWM Generator to go to 1 on rising edge compare value and to 0 on falling edge
compare value
Set the up/DoWn count mode and enable the PWM generator. Both generator updates
synchronised to zero count
return ReturnEvent;
// write separate function for each PWM channel to avoid precedence of action taken on load
value (no action) over compare values at 0 and 100
if duty is 100
else if duty is 0
void RestoreDutyCycle(void)