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

low_power_pwm_stop does not work increasing the consumption by 200 uA

Hello to all

I'm working in an application that needs to be completely power optimized. In this program the device works as a scanner that if it finds an specific device then puts a pwm in a pin, I already got this working with a low_power_pwm. The problem is that when the power_manage function is working, i.e, when the device is almost asleep, the consumption is 240uA, I managed to track 200 uA of this due to the low_power_pwm being activated, tried to use low_power_pwm_stop but didn't work it just keep the pin in a 100% duty, tried the solutions posted here, didn't work. The last thing I tried was sd_power_system_off but without an external wake up call it just stays in deep sleep and I believe even if this woke up with a timer, it wouldn't be a good option for my application. Appreciate any help you can give me, thanks :)

  • Can you also post the code where you turn the low_power_pwm off ?

  • static void on_ble_evt(ble_evt_t * p_ble_evt) {

        	switch (p_ble_evt->header.evt_id) {
        
        	case BLE_GAP_EVT_ADV_REPORT:
        		scan_filter(p_ble_evt);
        		break; // BLE_GAP_EVT_ADV_REPORT
        	.
                .
                .
        }
        
        uint8_t relevant_MAC[] = { 0xE6, 0x56, 0xDB, 0x4A, 0x93, 0xD0 };
        bool strcmp_MAC_PeerAddress;
        unsigned char i;
        static void scan_filter(ble_evt_t * p_ble_evt) {
        	/*Variable que nos guarda los datos del nuevo dispositivo*/
        	const ble_gap_evt_t * p_gap_evt = &p_ble_evt->evt.gap_evt;
        
        	const ble_gap_evt_adv_report_t * p_adv_report =
        			&p_gap_evt->params.adv_report;
        
        	strcmp_MAC_PeerAddress = memcmp((char *) relevant_MAC,
        			(char *) p_adv_report->peer_addr.addr, 6);
        
        	if (!strcmp_MAC_PeerAddress) {
        		flagRelevant_MAC = true;
        		
        		if (p_adv_report->data[2] == 0x00) {
        			flag_NoConnected = 1;
        		} else if (p_adv_report->data[2] == 0x01) {
        			flag_NoConnected = 2;
        		}
        	}
        }
    
  • Where are you calling low_power_pwm_stop(&low_power_pwm_2) ?

  • This is the Timer handler, the commented code are the functions I have tried to optimize the consumption:

    char interruptSeconds = 0;
    unsigned char flag_NoConnected = false;
    #define PIN_OUT 04
    bool flagRelevant_MAC = false;
    
    static void timer_timeout_handler(void * p_context) {
    	scanSeconds++;
    
    	if(!flagRelevant_MAC){
    		low_power_pwm_duty_set(&low_power_pwm_2, 100);
    		nrf_gpio_pin_clear(PIN_OUT);
    		//sd_power_system_off();
    		//sd_app_evt_wait();
    	}
    
    if (flag_NoConnected == 1 && flagRelevant_MAC == 1) {
    		low_power_pwm_start(&low_power_pwm_2, low_power_pwm_2.bit_mask);
    		if (interruptSeconds == 0) {
    			nrf_gpio_pin_set(PIN_OUT);
    			low_power_pwm_duty_set(&low_power_pwm_2, 60);
    		} else if (interruptSeconds == 1) {
    			low_power_pwm_duty_set(&low_power_pwm_2, 100);
    			nrf_gpio_pin_clear(PIN_OUT);
    
  • here continues

    } else if (interruptSeconds == 4) {
    			interruptSeconds = 0;
    			nrf_gpio_pin_set(PIN_OUT);
    			low_power_pwm_duty_set(&low_power_pwm_2, 60);
    			flagRelevant_MAC = false;
    		}
    		interruptSeconds++;
    	}
    
    	if (flag_NoConnected == 2 && flagRelevant_MAC == 1) {
    		//low_power_pwm_stop(&low_power_pwm_2);
    		low_power_pwm_duty_set(&low_power_pwm_2, 100);
    			//nrf_gpio_pin_clear(PIN_OUT);
    		nrf_gpio_pin_write(PIN_OUT, 1);
    		interruptSeconds = 0;
    		flagRelevant_MAC = false;
    	}	 
    	
    	if (scanSeconds == scanTime) {
    		sd_ble_gap_scan_stop();
    	}
    
    	if (scanSeconds >= (scanTime + noScanTime)) {
    		contador_dispositivos = 0;
    		scan_start();
    		scanSeconds = 0;
    	}
    }
    
Related