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.

COMPB will not generate interrupt on CC2650

Other Parts Discussed in Thread: CC2650

Hi

I am trying to get COMP to generate interrupt on a CC2650, but I can't get it to work. 

The code below that is comment out is gets interrupts from COMPA. To get ineterupt from COMPB I understand that I have to use the combined interrupt. That is what I am trying to do in the code but it doesn't trigger interrupt. The input signal is the same when I test for COMPA or COMPB.

Any suggestion on how to enable COMPB for interrupt in the MCU?

Regards Arne

	// Set ref and input on Comparator
	AUXWUCClockEnable(AUX_WUC_MODCLKEN0_SOC_M | AUX_WUC_MODCLKEN0_AUX_ADI4_M);

	// Enabling the 32kHz clock to comparator B
	DDI32BitsSet(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_ATESTCTL,
	DDI_0_OSC_ATESTCTL_SCLK_LF_AUX_EN);

//	HapiSelectCompAInput(ADC_COMPB_IN_AUXIO7);  // COMPA_REF_VSSA  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_AUXIO7);
	HapiSelectCompBRef(COMPB_REF_VDD1P2V);
	HWREGB(AUX_ADI4_BASE + ADI_4_AUX_O_COMP) |= ADI_4_AUX_COMP_COMPB_EN;

//	HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVTOMCUFLAGS) &= AUX_EVCTL_EVTOMCUFLAGS_AUX_COMPA;
//	IntRegister(INT_AUX_COMPA, &CompCallback);
//	IntEnable(INT_AUX_COMPA);

	HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVTOMCUFLAGS) &= AUX_EVCTL_EVTOMCUFLAGS_AUX_COMPB;
	HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_COMBEVTOMCUMASK) &= AUX_EVCTL_COMBEVTOMCUMASK_AUX_COMPB;
	IntRegister(INT_AUX_COMBO, &CompCallback);
	IntEnable(INT_AUX_COMBO);

 

  • Arne,

    Line 20 / 21 seems to be incorrect. You do a &= with a register that has reset value of 0x0, resulting in a 0 being written in.
    Also line 22 seems incorrect. In C, the function name is a pointer itself so you are providing a pointer to a pointer in your code.

    Regards,
    Svend
  • Also note that this code can cause issues with TI RTOS as you need to use the TI RTOS Hwi module to register interrupts to avoid overwriting the TI RTOS vector table when using the IntRegister function.
  • Hi Svend
    Of, course. Your right. I changed to |= and it worked like a charm.
    Can you elaborate on the TI RTOS Hwi module. Could you please tell me in more detail what I ought to do.

    Regards Arne
  • You can see how it is used in the SYS/BIOS user guide chapter 3.3.1:
    www.ti.com/.../spruex3o.pdf

    In our software examples we typically construct them dynamically using Hwi_construct instead of _create to have the structures static in memory instead of allocated on the RTOS heap.

    I also recommend the BLE software developers guide (SWRU393) for a good introduction to TI RTOS constructs.

    Regards,
    Svend
  • Hi Svend

    Thanks for answer!

    Now the comparator COMPB works fine, and I am also able to turn off the status flag from COMPB in my interrupt service routine. (See the interrupt service routine in the code attached).

    The problem is that turning off the flag doesn't seem to work when I use it in my BLE app (heartRateService). 

    When I modify pintInterrupt (the program that is included for the SensorTag example) everything works fine. If I include the same code into my heartRateService, then the interrupt is coming continuously. I am not able to turn of the COMPB flag.

    Is there a simple solution to this problem?

    Regards Arne

    void CompCallback() {
    
        // Read comparator
    	int compEvent = HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVSTAT0) & AUX_EVCTL_EVSTAT0_AUX_COMPB;
    	
    	// Reset compb flag
    	HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVTOMCUFLAGS) &= ~(AUX_EVCTL_EVTOMCUFLAGS_AUX_COMPB);
    
    	//...... some simple calculations
    
    	IntPendClear(INT_AUX_COMBO);
    }
    

  • Hi Arne,

    I checked with the RTOS development team and the INT_AUX_COMBO interrupt is also used by TI RTOS to use the TDC (time-to-digital converter) to calibrate the high-frequency RC oscillator to the correct frequency when you wake up from standby.

    This means that the AUX_COMBO interrupt cannot be used by the application from the Cortex M3.
    You can instead route the event through a programmable event:

    - Enable the event in AUX_EVCTL.EVTOAONFLAGS, use EVTOAONFLAGSCLR to clear it again.
    - Route the programmable event to the CPU using e.g. AON_EVENT:EVTOMCUSEL.AON_PROG0_EV
    - Register the interrupt using INT_AON_PRG0 instead (interrupt 45)

    Regards,
    Svend
  • Hi Svend

    Thanks for fast response.

    I have tried to follow your guideline, but still I am not able to turn off the interrupt from COMPB (se code below). This didn't work in the modified PinInterrupt context.

    Any more suggestions?

    Regards Arne

    void CompCallback() {
    
        // Read comparator
    	int compEvent = HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVSTAT0) & AUX_EVCTL_EVSTAT0_AUX_COMPB;
    	
    	// Reset compb flag
    	HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVTOAONFLAGSCLR) |= AUX_EVCTL_EVTOAONFLAGSCLR_AUX_COMPB;
    
    	//...... some simple calculations
    
    	IntPendClear(INT_AON_PRG0);
    }
    
    void Init() {
    	// Set ref and input on Comparator
    	AUXWUCClockEnable(AUX_WUC_MODCLKEN0_SOC_M | AUX_WUC_MODCLKEN0_AUX_ADI4_M);
    	// Enabling the 32kHz clock to comparator B
    	DDI32BitsSet(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_ATESTCTL,	DDI_0_OSC_ATESTCTL_SCLK_LF_AUX_EN);
    
    	HapiSelectADCCompBInput(ADC_COMPB_IN_AUXIO7);
    	HapiSelectCompBRef(COMPB_REF_VDD1P2V);
    	HWREGB(AUX_ADI4_BASE + ADI_4_AUX_O_COMP) |= ADI_4_AUX_COMP_COMPB_EN;
    	HWREGB(AUX_ADI4_BASE + ADI_4_AUX_O_COMP) |= ADI_4_AUX_COMP_COMPB_TRIM_DIV2;
    
    	//Enable flag
    	HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVTOMCUFLAGS) |= AUX_EVCTL_EVTOMCUFLAGS_AUX_COMPB;
    	//Route programmable event to CPU
    	HWREGB(AON_EVENT_BASE + AON_EVENT_O_EVTOMCUSEL) |= AON_EVENT_EVTOMCUSEL_AON_PROG0_EV_AUX_COMPB;
    	IntRegister(INT_AON_PRG0, &CompCallback);
    	IntEnable(INT_AON_PRG0);
    }