Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

app_timer use with uart_cli

I'm working on a cli_uart application on a PCA10040 board using SDK 17.0.0.  I started out by using the SDK peripheral example for twi_master with twis_slave as a base for the work.  Then I wanted to add a one second timer using app_timer to periodically sample connected twi sensors.  I was able to create the timer and the handler and build the project.  However, it appears the timer handler is called repetitively without any delay at all.  The number I put in the time define statement for APP_TIMER_TICKS has no effect. ?????

For now, this is a peripheral only application (no SoftDevice or BLE).

Can somebody suggest how to get around this and set up a timer to launch my sensor readings?

Thanks,

Max

   

Parents
  • Hi,

    Are you using app_timer.c or app_timer2.c? The original app_timer implementation has a known bug where it can expire immediately in some cases with high timeout values. This (and other issues) should be fixed in app_timer2. Migrating to app_timer2 is covered in the last part of the migration guide for SDK 16.

    If this is not the issue then it would be interesting to see your code in order to understand what is happening.

  • Einar,

    I went through the Application Timer Tutorial again and carefully reviewed the settings I was using.

    It turns out I missed applying the APP_TIMER_TICKS macro to the interval in app_timer_start.  I had a define all set up for it too!  As a result I got some integer value in there that was probably a much shorter interval than I was expecting.

    Once I got that straightened out, app_timer for a 1 second interval (using APP_TIMER_TICKS(1000) in app_timer_start) works fine in the SDK example twi_master_with_twis_slave.

    Max

Reply
  • Einar,

    I went through the Application Timer Tutorial again and carefully reviewed the settings I was using.

    It turns out I missed applying the APP_TIMER_TICKS macro to the interval in app_timer_start.  I had a define all set up for it too!  As a result I got some integer value in there that was probably a much shorter interval than I was expecting.

    Once I got that straightened out, app_timer for a 1 second interval (using APP_TIMER_TICKS(1000) in app_timer_start) works fine in the SDK example twi_master_with_twis_slave.

    Max

Children
No Data
Related