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

key delay and nrf_delay_ms() function

HI

   The SDK is "nRF5_SDK_for_Thread_and_Zigbee_v4.1.0" and I find a question that is: for all thread programs, add  nrf_ delay_ ms () function in while (true) will affect the operation delay of the key, what's the matter? 

  thanks!

Parents
  • You want a delay on a button in your application, is that correct? Please check out the button handler library, because a delay function in your main loop will just add a delay between what ever functions are on either side between the two.

    Best regards,

    Simon

  • Hi 

    Yes,you are right,but my question is adding a delay to the main loop  why cause a delay of button event? you can have a try ,so you can know what I say.  and if I add code segment in main loop it will cause button maybe invalid.

    thanks.

    static void bsp_event_handler(bsp_event_t event)
    {
        switch (event)
        {
            case BSP_EVENT_KEY_0:
                nrf_gpio_pin_clear(14);// new add
                //thread_coap_utils_unicast_light_request_send(THREAD_COAP_UTILS_LIGHT_CMD_TOGGLE);
                break;
    
    
    
    while (true)
        {
            thread_process();
            app_sched_execute();
           
            nrf_delay_ms(1000);  //new add
           
            if (NRF_LOG_PROCESS() == false)
            {
                thread_sleep();
            }
        }

Reply
  • Hi 

    Yes,you are right,but my question is adding a delay to the main loop  why cause a delay of button event? you can have a try ,so you can know what I say.  and if I add code segment in main loop it will cause button maybe invalid.

    thanks.

    static void bsp_event_handler(bsp_event_t event)
    {
        switch (event)
        {
            case BSP_EVENT_KEY_0:
                nrf_gpio_pin_clear(14);// new add
                //thread_coap_utils_unicast_light_request_send(THREAD_COAP_UTILS_LIGHT_CMD_TOGGLE);
                break;
    
    
    
    while (true)
        {
            thread_process();
            app_sched_execute();
           
            nrf_delay_ms(1000);  //new add
           
            if (NRF_LOG_PROCESS() == false)
            {
                thread_sleep();
            }
        }

Children
No Data
Related