/* Set the PWM duty of the PWM module. 
The  */
void PWMDutySet(unsigned long ulBase, unsigned long ulChannel, unsigned char ulDuty)
/* Set the PWM duty of the PWM module. 
The  */
void PWMDutySet(unsigned long ulBase, unsigned long ulChannel, unsigned char ulDuty)
{
    unsigned long ulChannelTemp;
    unsigned long ulCMRData;
    ulChannelTemp = (ulBase == PWMA_BASE) ? ulChannel : (ulChannel - 4);
    xASSERT((ulBase == PWMA_BASE) || (ulBase == PWMB_BASE));
    xASSERT(((ulChannelTemp >= 0) || (ulChannelTemp <= 3)));
    xASSERT(((ulDuty > 0) || (ulDuty <= 100)));
    ulCMRData = (xHWREG(ulBase + PWM_CNR0 +(ulChannelTemp * 12)) + 1) * 
                ulDuty / 100 - 1;
    if ((xHWREG(ulBase + PWM_CNR0 +(ulChannelTemp * 12)) + 1) *ulDuty / 100 == 0)
    {
        ulCMRData = 0;
    }
    xHWREG(ulBase + PWM_CMR0 +(ulChannelTemp * 12)) = ulCMRData;
}