/* Configure the compare data of an ADC digital comparator.  */
void ADCCompDataSet(unsigned long ulBase, unsigned long ulComp, unsigned long ulCompData, unsigned long ulMatchCnt)
/* Configure the compare data of an ADC digital comparator.  */
void ADCCompDataSet(unsigned long ulBase, unsigned long ulComp, unsigned long ulCompData, unsigned long ulMatchCnt)
{
    unsigned long ulCompRegAddr;
    unsigned long ulConfig;
    xASSERT(ulBase == ADC_BASE);
    xASSERT((ulComp >= 0) && (ulComp < 2));
    xASSERT(ulCompData < 0x0400);
    xASSERT(ulMatchCnt < 16);
    ulCompRegAddr = ulBase + ADC_CMPR0 + (4 * ulComp);
    ulConfig = ((ulCompData << ADC_CMPRX_CMPD_S) | 
                (ulMatchCnt << ADC_CMPRX_CMPMATCNT_S));
    xHWREG(ulCompRegAddr) &= ~(ADC_CMPRX_CMPD_M | ADC_CMPRX_CMPMATCNT_M);
    xHWREG(ulCompRegAddr) |= ulConfig;  
}