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

App timer limit

Hi, I'm using a simple timer with interval set using "APP_TIMER_TICKS(1.4, APP_TIMER_PRESCALER)" alongside softdevice. Now i'm trying to get it to go faster but it would advertise for at most 3 seconds and then the system would disconnect/timeout. I'd like to set it to "APP_TIMER_TICKS(0.5, APP_TIMER_PRESCALER)" to match the data frequency I require. Is there anyway to do this without spontaneous disconnections?

  • Personally I have had issues running the app_timer any faster than 2ms. What prescaler are you using?

  • What are you using this TIMER for? Why is this TIMER interval effecting the advertise? you said

    "Now i'm trying to get it to go faster but it would advertise for at most 3 seconds and then the system would disconnect/timeout"
    

    An advertiser would just broadcast, there are no connections yet, what do you mean by system disconnects after 3 seconds of advertise?

    The APP_TIMER library needs that the minumum timeout ticks to be 5, The clock frequence is 32768 Hz and you choose the prescaler so that you get atleast 5 ticks for your required time.

    copy paste from header, use this just for information as this might change with versions

        #define APP_TIMER_MIN_TIMEOUT_TICKS  5                          /**< Minimum value of the timeout_ticks parameter of app_timer_start(). */
    
    /**@brief Convert milliseconds to timer ticks.
     *
     * @note This macro uses 64 bit integer arithmetic, but as long as the macro parameters are
     *       constants (i.e. defines), the computation will be done by the preprocessor.
     *
     * @param[in]  MS          Milliseconds.
     * @param[in]  PRESCALER   Value of the RTC1 PRESCALER register (must be the same value that was
     *                         passed to APP_TIMER_INIT()). 
     * 
     * @note   When using this macro, it is the responsibility of the developer to ensure that the 
     *         values provided as input result in an output value that is supported by the
     *         @ref app_timer_start function. For example, when the ticks for 1 ms is needed, the
     *         maximum possible value of PRESCALER must be 6, when @ref APP_TIMER_CLOCK_FREQ is 32768.
     *         This will result in a ticks value as 5. Any higher value for PRESCALER will result in a
     *         ticks value that is not supported by this module.
     *
     * @return     Number of timer ticks.
     */
    #define APP_TIMER_TICKS(MS, PRESCALER)\
                ((uint32_t)ROUNDED_DIV((MS) * (uint64_t)APP_TIMER_CLOCK_FREQ, ((PRESCALER) + 1) * 1000))
    
  • Not disconnects..i mean the entire system shuts down like it can't take it...i'm using a prescaler of zero at the moment. If I put a value higher than 1.4 for MS, there's no problem but any lower and this happens. It has occurred on more than one sensor. My header file hasn't been edited so I know it can't be due to that.

  • you are getting 46 ticks with that macro which is far more than enough than the required. So that should not be a problem. Even if you choose too low value then it should not cause a system crash unless you are using too high priority for you app on your system. Difficult to say what else went wrong without seeing what you are doing in rest of your code.

Related