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

Where to put APP_TIMER_DEF without error or warning?

I am working on a project in Nordic SDK 8.1 that requires using a timer. I am confused where I need to define the timer though (using APP_TIMER_DEF). If I put it right after my #include statements I get the following error: ../../../main.c:39:1: warning: data definition has no type or storage class [enabled by default] APP_TIMER_DEF(m_slave_timeout_id);

I Googled the error and it said I need to place it in a function so there is somewhere for the data to be saved. Because of this I tried putting it at the top of my main() function. When I do that I get the following error though: main.c:(.text.startup.main+0x6): undefined reference to `APP_TIMER_DEF'

Where should I put this code?

Parents
  • I do not know if my answer will help you, but I used it like this:

    int You_want_function(void) { APP_TIMER_DEF(m_timer_id); app_timer_create(&m_timer_id, APP_TIMER_MODE_SINGLE_SHOT,timeout_handler); app_timer_start(m_timer_id, APP_TIMER_TICKS(5000, APP_TIMER_PRESCALER), NULL); }

    You can start as above in the some function you want to use.

Reply
  • I do not know if my answer will help you, but I used it like this:

    int You_want_function(void) { APP_TIMER_DEF(m_timer_id); app_timer_create(&m_timer_id, APP_TIMER_MODE_SINGLE_SHOT,timeout_handler); app_timer_start(m_timer_id, APP_TIMER_TICKS(5000, APP_TIMER_PRESCALER), NULL); }

    You can start as above in the some function you want to use.

Children
Related