This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2650 Can't get comperator COMPB to work. (COMPA works fine)

Hi

I am not able to get COMPB to work. The reason for using COMPB instead of COMPA is the ability to trim the input value, that seems to be valid only for COMPB. The test program below is running on SmartTag. When the input on AUXIO5 goes above 1.2V it turns on respective led, and clear the event flag. When signal goes below 1.2V the led is turned off. 
This works fine if I use COMPA (the code that I have comment out). But, when I use the same settings for COMPB, the flag is never turned off.
What am I doing wrong here? 
Regards Arne
-------------------------------
PIN_Config myLedPinTable[] = {
    Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    Board_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW  | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    PIN_TERMINATE
};

PIN_Config myButtonPinTable[] = {
    Board_KEY_RIGHT  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
    Board_KEY_LEFT   | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
    PIN_TERMINATE
};

PIN_Config AnalogInputPins[] = {
	Board_DP0 | PIN_INPUT_DIS | PIN_GPIO_OUTPUT_DIS ,
	PIN_TERMINATE
};


int main(void)
{
    /* Call board init functions */
    Board_initGeneral();

    // Open Analog Pins
    board_DP0PinHandle = PIN_open(&board_DP0PinState, AnalogInputPins);

    /* Open LED pins */
    myLedPinHandle = PIN_open(&myLedPinState, myLedPinTable);
    if(!myLedPinHandle) {
        System_abort("Error initializing board LED pins\n");
    }

    myButtonPinHandle = PIN_open(&myButtonPinState, myButtonPinTable);
    if(!myButtonPinHandle) {
        System_abort("Error initializing button pins\n");
    }

    AUXWUCClockEnable(AUX_WUC_MODCLKEN0_SOC_M|AUX_WUC_MODCLKEN0_AUX_ADI4_M);

    //HapiSelectCompAInput(COMPA_IN_AUXIO5);
    //HapiSelectCompARef(COMPA_REF_VDD1P2V);
    //HWREGB(AUX_ADI4_BASE + ADI_4_AUX_O_COMP) = ADI_4_AUX_COMP_COMPA_EN;

    HapiSelectADCCompBInput(ADC_COMPB_IN_AUXIO5);
    HapiSelectCompBRef(COMPB_REF_VDD1P2V);
    HWREGB(AUX_ADI4_BASE + ADI_4_AUX_O_COMP) |= ADI_4_AUX_COMP_COMPB_EN;

    while (true)
    {
   	    int compAeventAux= HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVSTAT0) & AUX_EVCTL_EVSTAT0_AUX_COMPA;
   	    int compBeventAux= HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVSTAT0) & AUX_EVCTL_EVSTAT0_AUX_COMPB;

   	    if (compAeventAux > 0)
   	    {
   	    	PIN_setOutputValue(myLedPinHandle, Board_LED1, 1);
   	   	    HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVSTAT0) &= ~(AUX_EVCTL_EVSTAT0_AUX_COMPA);
   	    }
   	    else
   	    	PIN_setOutputValue(myLedPinHandle, Board_LED1, 0);

   	    if (compBeventAux > 0)
		{
			PIN_setOutputValue(myLedPinHandle, Board_LED2, 1);
   	   	    HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVSTAT0) &= ~(AUX_EVCTL_EVSTAT0_AUX_COMPB);
		}
		else
		{
			PIN_setOutputValue(myLedPinHandle, Board_LED2, 0);
		}
    }
    return (0);
}

  • Hi Arne,

    There is a bit enabling the 32kHz clock to comparator B that are not set by default.

    This can configured in the oscillator module as shown below. The bit is unfortunately placed in a hidden test register so you need to define a couple of variables yourself.

    #include <inc/hw_memmap.h>
    #include <driverlib/ddi.h>
    #include <driverlib/hw_ddi_0_osc.h>
    #define DDI_0_OSC_O_ATESTCTL 0x00000020
    #define DDI_0_OSC_ATESTCTL_SCLK_LF_AUX_EN 0x20000000
    
    DDI32BitsSet(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_ATESTCTL, DDI_0_OSC_ATESTCTL_SCLK_LF_AUX_EN)
    

    To verify that it was correctly set you can read out the word at 0x400CA020 and check that bit 29 is "1".

    Regards,
    Svend