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

Question about stopping all the timers that are used in the application.

Hi Everyone

I have got 3 timers in my application. 

1 is repeated , and other two are Single shot which are ran from the inputs to the 1st Repeated timer.

The repeated keeps checking the UART for a byte , once the byte is received , One single shot timer is started , which on expiry turn One of my sensor OFF and inside the handler starts another single shot timer which again turns ON the sensor after 1 hour. 

If i stop the repeated timer when i turn OFF the Sensor , and start the Timer when I turn ON the sensor again. The whole thing just comes to a halt and it doesn't work anymore.

I have fixed this issue by using a timer of 10 seconds , which does literally nothing but keep repeating after 10 seconds, but i am not sure if the theory is correct or not.

""If all the timers have been turned OFF , the RTC goes to deep-sleep and it doesn't count anymore and to keep the RTC alive , i have used a repeated timer as desribed above.

It works in this configuration , but i am not sure if the reasoning is correct or not.""

Kindly help me understand this behavior.

Thanks 

Rajat

  • I don't need to reproduce, but it is easier to navigate in your project to see what you are doing if I have the project. Your APP_TIMER_CONFIG_RTX_FREQUENCY is 0, meaning your app_timer is running on 32768Hz. 

    Where do you set your prescaler to 15?

  • /** @file timer_interra.c
    *
    * @brief A Timer used to generate the delay functionality, will later try to execute events.
    *
    * @par
    * NOTICE: Property of in-Terra Limited www.in-terra.ch .
    */
    
    
    #include "timer_interra.h"
    
    APP_TIMER_DEF(m_led_0_timer_id);
    
    uint8_t timer_exp_flag=0;
    
    void timer_0_handler(void * p_context)
    { 
        timer_exp_flag=1; 
        
           
    }
    
    
    /*!
     * @brief Delay using the app timer
     *
     * @param[in] None
     *
     * @return    None
     */
    
    uint8_t delay()
    {
    
        if (timer_exp_flag == 1)
            {
                timer_exp_flag = 0;
    
                return 1;
            }
        else
            {   
                return 0;
            }
    }
    
    
    /*!
     * @brief Delay using the app timer
     *
     * @param[in] None
     *
     * @return    None
     */
    
    uint8_t timer_ms(uint32_t time_miliseconds)
    {
    
    uint32_t err_code;
     
        err_code = app_timer_create(&m_led_0_timer_id,
                                    APP_TIMER_MODE_SINGLE_SHOT,
                                    timer_0_handler);
        APP_ERROR_CHECK(err_code);
    
        // Start timers
        err_code =app_timer_start(m_led_0_timer_id, APP_TIMER_TICKS(time_miliseconds), NULL);
        APP_ERROR_CHECK(err_code);
        
      while(delay()!=1);
    
     // while(timer_exp_flag!=1);
    }
    
    
    
    
    /*!
     * @brief Initilaize the Timer
     *
     * @param[in] None
     *
     * @return    None
     */
    
    void
    timer_init (void)
    {
        
    ret_code_t err_code;
    err_code=app_timer_init();
    
     SEGGER_RTT_printf(0,"Error Code is %ld\r\n", err_code);      
       
    }
    
    /*!
     * @brief start the Timer
     *
     * @param[in] milsecond to expire
     *
     * @return    None
     */
    
    void
    timer_start(uint32_t ms_time)
    {
        
    
            
       
    }
    timer_interra.h

  • Inside timer_interra.h , i have defined

    #define APP_TIMER_PRESCALER             15 

  • APP_TIMER_CONFIG_RTC_FREQUENCY 0

    or is it this value that decides everything ahead in the software?

    I am confused. :(

  • i am not able to upload the whole project , it says Error when i upload the zip file.

Related