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

Timer or RTC for 5 - 60 sec delay

Hi All, I am using the Nordic nRF52 nrf52832 device to read a value in from an Android device. The value will be between 5 and 60 seconds. I'm using the experimental_ble_app_blinky to control the BLE side of things. Is it best to use RTC or will a simple delay do the job. Thanks

  • If by "simple delay" you mean nrf_delay_us or nrf_delay_ms then NO, you should never use these functions in multipurpose application with BLE. It is blocking code so MCU won't be usable for that time (= you effectively kill it for the time of delay). Always prefer RTC based timers (e.g. app_timer library is great and simple to use).

  • Thanks endnode, I'm using s132 and can't find app_timer in the examples. There is an example for rtc in peripherals, but when I port into my code I get the following compiler errors:

    ......\main.c(199): error: #20: identifier "RTC_DEFAULT_CONFIG_FREQUENCY" is undefined nrf_drv_rtc_config_t config = RF_DRV_RTC_DEFAULT_CONFIG; ......\main.c(199): error: #20: identifier "RTC_DEFAULT_CONFIG_IRQ_PRIORITY" is undefined nrf_drv_rtc_config_t config = RF_DRV_RTC_DEFAULT_CONFIG; ......\main.c(199): error: #20: identifier "RTC_DEFAULT_CONFIG_RELIABLE" is undefined nrf_drv_rtc_config_t config = RF_DRV_RTC_DEFAULT_CONFIG; ......\main.c(199): error: #20: identifier "NRF_MAXIMUM_LATENCY_US" is undefined

  • Go to root of SDK and search for app_timer.. or let me do it for you: components\libraries\timer\. Now how to use this library you can see in many example projects, just search for app_timer_init in all *.c files (my search shows over 90 matches;)

Related