Using: nRF52840-QIAA(build code: C0) 1024kB, GCC 8.2.1, Debug build (-O0), Softdevice S140 7.0.1, SDK v16.0.0
Source code:
#include <libraries/timer/app_timer.h> #include <nrf_gpio.h> #include <nrf_sdh.h> #include "nrf_log.h" #include "nrf_log_ctrl.h" #include "nrf_log_default_backends.h" NRF_LOG_INTERNAL_MODULE_REGISTER(); APP_TIMER_DEF(test_timer); static void log_init() { ret_code_t err_code = NRF_LOG_INIT(nullptr); APP_ERROR_CHECK(err_code); NRF_LOG_DEFAULT_BACKENDS_INIT(); } static void test_timer_handler(void *p_context) { UNUSED_PARAMETER(p_context); nrf_gpio_pin_toggle(21); } void timer_init() { ret_code_t err_code = app_timer_init(); APP_ERROR_CHECK(err_code); err_code = app_timer_create(&test_timer, APP_TIMER_MODE_REPEATED, test_timer_handler); APP_ERROR_CHECK(err_code); } void timer_start() { ret_code_t err_code; NRF_LOG_INFO("Before timer start"); err_code = app_timer_start(test_timer, APP_TIMER_TICKS(2000), nullptr); APP_ERROR_CHECK(err_code); NRF_LOG_INFO("After timer start"); } int main() { log_init(); ret_code_t err_code = nrf_sdh_enable_request(); APP_ERROR_CHECK(err_code); timer_init(); nrf_gpio_cfg_output(21); nrf_gpio_pin_toggle(21); timer_start(); // Enter main loop. for (;;) { err_code = sd_app_evt_wait(); APP_ERROR_CHECK(err_code); } }
In UART console i see:
<info> app_timer: RTC: initialized.
<info> app: Before timer start
So program freezed/crashed in app_timer_start.
If i connect debugger it shows that program is running, and when i pause is shows that in paused in Handler External Interrupt(17) and has backtrace:
#0 WDT_IRQHandler () at /home/server/Programming/NRF/NRF_SDK/modules/nrfx/mdk/gcc_startup_nrf52840.S:358 No locals. #1 <signal handler called> No symbol table info available. #2 0x00028efe in NVIC_SetPendingIRQ (IRQn=RTC1_IRQn) at /home/server/Programming/NRF/NRF_SDK/components/toolchain/cmsis/include/core_cm4.h:1664 No locals. #3 0x0002957a in drv_rtc_irq_trigger (p_instance=0x20002ecc <m_rtc_inst>) at /home/server/Programming/NRF/NRF_SDK/components/libraries/timer/drv_rtc.c:333 No locals. #4 0x00028bd2 in timer_request_proc_trigger () at /home/server/Programming/NRF/NRF_SDK/components/libraries/timer/app_timer2.c:483 No locals. #5 0x00028c1e in timer_req_schedule (type=TIMER_REQ_START, p_timer=0x20003750 <test_timer_data>) at /home/server/Programming/NRF/NRF_SDK/components/libraries/timer/app_timer2.c:510 fifo_ctx = {last_tail = {tag = 0, pos = {wr = 0, rd = 0}}} p_req = 0x20003578 <m_req_fifo_data> #6 0x00028d44 in app_timer_start (p_timer=0x20003750 <test_timer_data>, timeout_ticks=32768, p_context=0x0) at /home/server/Programming/NRF/NRF_SDK/components/libraries/timer/app_timer2.c:590 p_t = 0x20003750 <test_timer_data> #7 0x0002da58 in timer_start () at /home/server/Programming/NRF/timer_test/main.cpp:39 err_code = 1342177280 #8 0x0002dae4 in main () at /home/server/Programming/NRF/timer_test/main.cpp:56 err_code = 0 #9 0x0002728e in _start ()
I'm using modified sdk_config from examples/ble_peripheral/ble_app_template/pca10056/s140/config/, diff:
< #define NRFX_CLOCK_CONFIG_LF_SRC 1 > #define NRFX_CLOCK_CONFIG_LF_SRC 2 < #define CLOCK_CONFIG_LF_SRC 1 > #define CLOCK_CONFIG_LF_SRC 2 < #define NRF_LOG_BACKEND_UART_TX_PIN 6 > #define NRF_LOG_BACKEND_UART_TX_PIN 19 < #define NRF_LOG_DEFERRED 1 > #define NRF_LOG_DEFERRED 0 < #define NRF_SDH_CLOCK_LF_SRC 1 > #define NRF_SDH_CLOCK_LF_SRC 2
Changed LF_SRC because on 1 program was not starting, only on 0 or 2.
Defines used to build:
-DAPP_TIMER_V2 -DAPP_TIMER_V2_RTC1_ENABLED -DBOARD_CUSTOM -DCONFIG_GPIO_AS_PINRESET -DFLOAT_ABI_HARD -DNRF52840_XXAA -DNRF_SD_BLE_API_VERSION=7 -DS140 -DSOFTDEVICE_PRESENT -DAPP_RAM_START=0x20002E78 -DRAM_SIZE=0x3D188 -DDEBUG
Why program is stuck after requesting interrupt ? How can i fix it ?