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

Can I use BSP_BUTTON_ACTION_LONG_PUSH w/ FreeRTOS?

Hi, for my project (its based on FreeRTOS) I was trying to reassign button actions in order to detect a long push event, what obviously doesn't work at all. In bsp.c i saw that app_timer_create/start/stop will be used to detect long pushed events. So my assumption is that app_timer is kind of disabled on using FreeRTOS. Am I right?

It works if I start a rtos xTimer on button pushed event and stop it respectively on button released event. But I'd rather prefer using bsp library. Any hints?

  • Hi Chrizz, Which app_timer files are you using? With freertos you have different files that does not use RTC, but uses freertos internal timers instead.

    Also have you tried applying this below patch

    freertos.zip

    You need to add this below in your FreeRTOSConfig.h file

    /** Implementation note: Use this with caution and set this to 1 ONLY for debugging
    
     * Set the value of configUSE_DISABLE_TICK_AUTO_CORRECTION_DEBUG to below for enabling or disabling RTOS tick auto correction:
     * 0. This is default. If the RTC tick interrupt is masked for more than 1 tick by higher priority interrupts, then most likely
     *    one or more RTC ticks are lost. The tick interrupt inside RTOS will detect this and make a correction needed. This is needed
     *    for the RTOS internal timers to be more accurate.
     * 1. The auto correction for RTOS tick is disabled even though few RTC tick interrupts were lost. This feature is desirable when debugging
     *    the RTOS application and stepping though the code. After stepping when the application is continued in debug mode, the auto-corrections of
     *    RTOS tick might cause asserts. Setting configUSE_DISABLE_TICK_AUTO_CORRECTION_DEBUG to 1 will make RTC and RTOS go out of sync but could be
     *    convenient for debugging.
     */
    define configUSE_DISABLE_TICK_AUTO_CORRECTION_DEBUG 0
    
  • Aryan, I'm using the app_timer_freertos.c implementation but didn't try the patch yet. On the other hand I'm using FreeRTOS 9.0.0 to gain from xTaskGetHandle method. What exactly is the difference between FreeRTOS shipped with 12.2.0 and the patched version? Grepping for configUSE_DISABLE_TICK_AUTO_CORRECTION_DEBUG I saw changes in port_cmsis_systick.c

  • without the patch , if freertos tick interrupt is masked for more than 1 tick period , then there was possibilities that the tick is lost. This would cause freertos internal timers drift over time. The patch applies an automatic correction to the freertos internal timer based on the rtc tick keeping them in sync always no matter how long the freertos tick is masked.

Related