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

QDEC high power consumption

Hello. Project im developing requires low power wireless encoder. NRF52832 is a really impressive chip that handles everything i need within 40uA. But I've got problem with QDEC. I just can't get it running with current consumption less than 400uA. SDK QDEC example also consumes 400uA, but datasheet specifies current of 5uA. As I can see, there is 3 possible options:

1) I'm making something wrong and there is a way to run QDEC with high efficiency

2) Forget about QDEC and process data in RTC IRQ - possible data losses due to softdevice IRQs

3) Connect RTC to QDEC START task using PPI and short SAMPLERDY event to STOP task

I have no idea about reason why current consumption is so high. Time between samples is 128 * 2^SAMPLEPER us -  so maybe QDEC uses PCLK1M? But I found no information about clock source of QDEC. It would be nice if there would be some undeclared/reserved register that could solve the problem. Probably someone should have thought about connecting QDEC to LF clock. 

However, it's all just a bunch of random guesses. I have no information about detailed QDEC architecture and just hoping for best

Parents
  • Hi,

     

    The QDEC peripheral requires the 16M clock tree to run, which adds approx. 400 uA (depending on the HFCLK source) in sleep. The recommended method, wrt. power consumption, is to enable the QDEC when required, and disable it before going to sleep. You can use a pin-interrupt on both inputs to re-enable the QDEC when waking up from sleep.

     

    Best regards,

    Håkon

  • Thank you for clarification. I will try to use PPI then. Unfortunately, encoder draws 15 mA while sensing, so there is no way to use GPIOTE

  • Yes, it works excellent. QDEC draws only 0.8uA. RTC instance required, however. I am providing sample code in case someone would encounter same problems. 

    int main(void)
    {  
    	
    	NRF_CLOCK -> TASKS_LFCLKSTART = 1;
    	while((NRF_CLOCK -> LFCLKSTAT  & CLOCK_LFCLKSTAT_STATE_Msk) == 0);
    	
    	NRF_RTC0 -> PRESCALER = 60;
    	NRF_RTC0 -> EVTENSET =1;
    	NRF_RTC0 -> TASKS_START = 1;
    	
    	NRF_QDEC ->ENABLE = 1;
    	NRF_QDEC ->SHORTS = 2;
    	NRF_QDEC ->LEDPOL = 0;
    	NRF_QDEC ->LEDPRE = 10;
    	NRF_QDEC ->SAMPLEPER = 0;
    	NRF_QDEC ->PSEL.A = 25;
    	NRF_QDEC ->PSEL.B = 24;
    	NRF_QDEC ->PSEL.LED = 20;	
    	
    	NRF_PPI ->CH[0].EEP = (uint32_t)&(NRF_RTC0 ->EVENTS_TICK);
    	NRF_PPI ->CH[0].TEP = (uint32_t)&(NRF_QDEC->TASKS_START);
    	NRF_PPI ->CHENSET=1;
    	
    	while(true){
    	 __SEV();
    	__WFI();
    	__WFI();
    	}	
    	
    }

Reply
  • Yes, it works excellent. QDEC draws only 0.8uA. RTC instance required, however. I am providing sample code in case someone would encounter same problems. 

    int main(void)
    {  
    	
    	NRF_CLOCK -> TASKS_LFCLKSTART = 1;
    	while((NRF_CLOCK -> LFCLKSTAT  & CLOCK_LFCLKSTAT_STATE_Msk) == 0);
    	
    	NRF_RTC0 -> PRESCALER = 60;
    	NRF_RTC0 -> EVTENSET =1;
    	NRF_RTC0 -> TASKS_START = 1;
    	
    	NRF_QDEC ->ENABLE = 1;
    	NRF_QDEC ->SHORTS = 2;
    	NRF_QDEC ->LEDPOL = 0;
    	NRF_QDEC ->LEDPRE = 10;
    	NRF_QDEC ->SAMPLEPER = 0;
    	NRF_QDEC ->PSEL.A = 25;
    	NRF_QDEC ->PSEL.B = 24;
    	NRF_QDEC ->PSEL.LED = 20;	
    	
    	NRF_PPI ->CH[0].EEP = (uint32_t)&(NRF_RTC0 ->EVENTS_TICK);
    	NRF_PPI ->CH[0].TEP = (uint32_t)&(NRF_QDEC->TASKS_START);
    	NRF_PPI ->CHENSET=1;
    	
    	while(true){
    	 __SEV();
    	__WFI();
    	__WFI();
    	}	
    	
    }

Children
No Data
Related