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 Reply Children
  • Thanks Einar.  I see app_timer2.c is being used.

    In the meantime, I tried setting up a hardware nrfx_timer using a method outlined in this forum.  That seems to be working nicely but I have some more testing to do.

    Before sending a code sample, I think I'll go back to a copy the original example and just add an app_timer to that to make sure I didn't mess up with other things I was trying to implement.  That would be additional CLI commands and some GPIO with a PWM output.  I'll let you know what that reveals.

    Max

  • 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

Related