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

how to set the Timer for 3 sec

Hello everyone i ahve configured the button and i want to make the function like this press the button for 3 sec and then the device should start advertising can anyone suggest me how to set the timer and how to enable the advertsingmode after the button is pressed for 3 sec or more any suggestion or help will be most useful for me

Thank you

Parents
  • Conceptionally, I would use the RTC to determine the duration that the button was held. Bare in mind, you will have to take into account the de-bouncing of the button.When the button is pressed, I would clear the timer. When the button is released, have the GPIO for the button trigger (possibly PPI) a timer compare. Knowing the scaling factor that you used to initialize the RTC, you can know whether the button was held for 3 seconds, if so, then use the soft device to enable advertising using err = sd_ble_gap_adv_data_set( currentAdvertisementPacket, currentAdvertisementPacketLength, NULL, 0); followed by APP_ERROR_CHECK(err);

    Hopefully that helped.

Reply
  • Conceptionally, I would use the RTC to determine the duration that the button was held. Bare in mind, you will have to take into account the de-bouncing of the button.When the button is pressed, I would clear the timer. When the button is released, have the GPIO for the button trigger (possibly PPI) a timer compare. Knowing the scaling factor that you used to initialize the RTC, you can know whether the button was held for 3 seconds, if so, then use the soft device to enable advertising using err = sd_ble_gap_adv_data_set( currentAdvertisementPacket, currentAdvertisementPacketLength, NULL, 0); followed by APP_ERROR_CHECK(err);

    Hopefully that helped.

Children
Related