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

How can I wake up cpu when I use sd_app_event_wait() to manage power?

When I use ble_app_hids_mouse demo to test my mouse sensor, it seems that mouse arrow will delay about 300ms to start send data ,at the beginning of movement.

When I cut the function "power_manage()", delay phenomenon is solved but the arrow will not smooth anymore.

How can I do to keep it move smooth and solve the delay problem cause by "sd_app_event_wait()" ?

Is there any func to wake up the cpu from "sd_app_event_wait()"?

  • Any enabled interrupt will wake the CPU from sd_app_evt_wait(). Please take a look at this question for details.

    It's impossible to say much more without taking a look at your complete code project. Feel free to create a support case and upload it there if you need more help.

  • That's very kind of you.

    /**@brief Function for the Power manager. */ static void power_manage(void) { uint32_t err_code = sd_app_event_wait(); APP_ERROR_CHECK(err_code); }

    /**@brief Function for application main entry.
     */
    int main(void)
    {
        timers_init();
        gpiote_init();
        buttons_init();
    	sensor_init();
        bond_manager_init();
        ble_stack_init();
        scheduler_init();
        gap_params_init();
        advertising_init(BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE);
        services_init();
        sensor_sim_init();
        conn_params_init();
        sec_params_init();
        radio_notification_init();
        
    	//NRF_POWER->TASKS_CONSTLAT = 1; //try to get in to CONSTLAT mode
    
        timers_start();
        advertising_start();
        
        // Enter main loop.
        for (;;)
        {	
    
    		if(button_pressed == true)
    			button_check();		
    
    		mouse_sensor_send();
            app_sched_execute();
            power_manage();
        }
    }
    

    I can tell by logic analyzer that it always take about 300ms to wake up from "sd_app_event_wait()", this will cause problem that I can't move mouse smoothly at the start. Sensor date will accumulate during this 300ms.

    I must short the wake up time.

    And I try to enable constant latency mode by "NRF_POWER->TASKS_CONSTLAT = 1;" , but after I add this code, I can't even find my BLE device by Android 4.4 or win8.1 PC.

    The hole project as attachment.

    OS : Win8.1 / Nexus 7 II (Android 4.4.2) SD: s110_nrf51822_5.2.1_softdevice SDK: nrf51_sdk_v4_4_2_33551

    HW: nrf51822 DK

Related