/* Sets the pulse width for the specified PWM output. */
void PWMPulseWidthSet(unsigned long ulBase, unsigned long ulPWMOut, unsigned long ulWidth)
/* Sets the pulse width for the specified PWM output. */
void PWMPulseWidthSet(unsigned long ulBase, unsigned long ulPWMOut, unsigned long ulWidth)
{
    unsigned long ulGenBase, ulReg;
    ASSERT(ulBase == PWM_BASE);
    ASSERT(PWMOutValid(ulPWMOut));
    ulGenBase = PWM_OUT_BADDR(ulBase, ulPWMOut);
    if(HWREG(ulGenBase + PWM_O_X_CTL) & PWM_X_CTL_MODE)
    {
        ulWidth /= 2;
    }
    ulReg = HWREG(ulGenBase + PWM_O_X_LOAD);
    ASSERT(ulWidth < ulReg);
    ulReg = ulReg - ulWidth;
    if(PWM_IS_OUTPUT_ODD(ulPWMOut))
    {
        HWREG(ulGenBase + PWM_O_X_CMPB) = ulReg;
    }
    else
    {
        HWREG(ulGenBase + PWM_O_X_CMPA) = ulReg;
    }
}