/* Set the PWM frequency of the PWM module. 
The  */
unsigned long PWMFrequencySet(unsigned long ulBase, unsigned long ulFrequency)
/* Set the PWM frequency of the PWM module. 
The  */
unsigned long PWMFrequencySet(unsigned long ulBase, unsigned long ulFrequency)
{
    unsigned long ulFrepDiv;
    unsigned long ulActualFrep;
    unsigned long ulPreScale;
    unsigned short usCNRData;
    xASSERT((ulBase == PWMA_BASE) || (ulBase == PWMB_BASE));
    xASSERT((ulFrequency > 0) || (ulFrequency <= xSysCtlClockGet(ulBase)));
    ulFrepDiv =  xSysCtlClockGet() / ulFrequency;
    ulPreScale = 1;
    while((ulFrepDiv / ulPreScale) > 0xFFFF)
    {
        ulPreScale++;
    }
    if(ulPreScale > 0xFFFF)
    {
        return 0;
    }
    usCNRData = ulFrepDiv / ulPreScale;
    xHWREG(ulBase + TIMER_CRR) = usCNRData;
    xHWREG(ulBase + TIMER_PSCR) = ulPreScale - 1;
    ulActualFrep = xSysCtlClockGet() / usCNRData / ulPreScale;
    return ulActualFrep;
}