This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

GPIO and COMP strange behavior

Im trying to detect power off. The signal power off looks like:

The time to get 0V equal 15seconds. GPIO EVENT and COMP do not see changes in the voltage level, they are blind.

But when signal looks like

then it works fine.

COMP works with hysteresis. Start signal level is 2.4V Threshold id 1.8V or 1.2V. 

What can be source of problem?

  • Hi,

    Are you using the COMP in differential or in signal ended mode? What are you using as a reference voltage? Could you share the code that you're using to sense the signal change? 

    Regards

    Jared 

  • Initialization code


        NRF_GPIO->PIN_CNF[4]=0x04;  // INPUT - AnalogInput2
        NRF_GPIO->PIN_CNF[9]=0x03;  // OUTPUT - LED
    
        NRF_COMP->PSEL=COMP_PSEL_PSEL_AnalogInput2;
        NRF_COMP->MODE=COMP_MODE_MAIN_SE<<COMP_MODE_MAIN_Pos;   
        
        NRF_COMP->REFSEL=COMP_REFSEL_REFSEL_Int1V2<<COMP_REFSEL_REFSEL_Pos;
        NRF_COMP->TH|= (5<<COMP_TH_THDOWN_Pos) | 5<<COMP_TH_THUP_Pos;
        NRF_COMP->HYST=COMP_HYST_HYST_Hyst50mV;
    
        NRF_COMP->INTENSET= (COMP_INTEN_UP_Enabled<<COMP_INTEN_UP_Pos) | (COMP_INTEN_DOWN_Enabled<<COMP_INTEN_DOWN_Pos);
    
        NRF_COMP->ENABLE=COMP_ENABLE_ENABLE_Enabled;
    
        NVIC_SetPriority( COMP_LPCOMP_IRQn, 0 );
    	NVIC_ClearPendingIRQ( COMP_LPCOMP_IRQn );
        NVIC_EnableIRQ(COMP_LPCOMP_IRQn);
    		
    	NRF_COMP->TASKS_START=1;

    Interrupt Code

    void COMP_LPCOMP_IRQHandler(void)
    {
    	NVIC_ClearPendingIRQ( COMP_LPCOMP_IRQn );
    
    	NRF_COMP->EVENTS_READY=0;
    	NRF_COMP->EVENTS_DOWN=0;
    	NRF_COMP->EVENTS_UP=0;
    	NRF_COMP->EVENTS_CROSS=0;
    
    
    	if(NRF_COMP->RESULT==1)
    	NRF_GPIO->OUTCLR=1<<9;
    	else
    	NRF_GPIO->OUTSET=1<<9;
    
    }

  • Hi,

    The issue can be related to this errata. Could you try using the LPCOMP instead and see if you experience the same issue? Also, notice this errata regarding LPCOMP.

    Regards

    Jared 

Related