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.

How to control comparators on CC2650 and clearing events.

Other Parts Discussed in Thread: CC2650

Hi

I am trying to use the analog comparator (COMPA) to trigger interrupts. That works fine in the code shown below, but my problem is to clear interrupts. 

I have figured out how to clear the interrupt by using: IntPendClear(INT_AUX_COMPA);
However, that doesn't seem to stop the COMPA from interrupting when the input signal gets below the reference signal again.
I have tested by modifying the PIN_Interrupt project, running it on SensorTag (cc2650). I am setting up COMPA to take input from AUXIO5 and using 1.2V as reference. I also register for callback, and enables the interrupt. This works fine:
    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; //ADI_4_AUX_COMP_COMPA_EN;
When I rise the voltage above 1.2 V on AUXIO5, that triggers the interrupt and my interrupt service routine is called:
void CompCallback()
{
 IntPendClear(INT_AUX_COMPA);
 //IOCIntClear(INT_AUX_COMPA);
     //IntDisable(INT_AUX_COMPA);
 uint32_t currVal= adcSingleAin(ADC_COMPB_IN_AUXIO5); 
 currVal =  PIN_getOutCOMPA putValue(Board_LED1);
     PIN_setOutputValue(myLedPinHandle, Board_LED1, !currVal);
     //IntEnable(INT_AUX_COMPA);
}
In my service routine I am trying clear the interrupt, so it will not receive interrupts when the signal on AUXIO5 is lowered below 1.2V. As the code now works, COMPA will trigger the interrupt service routine, even when the signal is below the reference. That happens only when the signal has been above 1.2 V. So, it will not be called before the signal goes above 1.2V the first time.
How can I clear from sending interrupts when input signal is below the reference signal?
How can I read the output from COMPA?
How can I get COMPA to be triggered on positive edge?
Best regards Arne
  • Hello Arne,
    Have you considered using sensor controller studio instead?
    We currently don't have a proper COMPA RTOS driver, but the implementation in sensor controller studio can achieve robust and low power operation.

    I think you need to clear the AUX_COMPA flag in the EVTOMCUFLAGS register (AUX_EVCTL register) before you clear MCU flag (IntPendClear(INT_AUX_COMPA)). The polarity is set in EVTOMCUPOL and is by default set to 0h (high level) which is what you want?

    Also make sure to set a power constraint for the aux domain or disable power saving when using the COMPA.

  • Hi Erik

    I have looked into Sensor Controller Studio, but I found it a bit hard to test the code. Looking forward to next release where I understand that you are able to test the code directly from Sensor Controller Studio.

    However, I tested your solution by clearing the events from AUX, and it worked!

    Thanks a lot!

    Regards Arne

  • Great,

    That is right. I think the next release (1.1.0) should be within next week.