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

GetTick ?

Dear Members,

How can I GetTick from the CPU? similar to HAL_GetTick() ?

nrf_drv_systick_get ?

Thanks

  • Hello,

    That is not that trivial. What do you intend to use this for? Do you want to measure something in ms? If so, what you need to do is to start either a timer or an rtc. 

    If you want to create a timer with a timeout, then you can use e.g. the app_timer. 

    What sort of resolution do you need? minutes? seconds? ms? µs? 

    I recommend that you check out the app_timer, which is used e.g. in the example ble_app_hrs. 

    Look at how battery_level_meas_timeout_handler() which is a timeout handler is set up to time out every 2 seconds.

    If you set up and start the app_timer, you can also use the function app_timer_cnt_get() to get the tick number for the RTC (in fact, it uses the function drv_rtc_counter_get(), which you mentioned). But please note that the amount of time that these ticks represents depends on how the RTC is set up (frequency and prescaler)

    Also, this function app_timer_cnt_diff_compute() or drv_rtc_counter_get() only works if the RTC (and app_timer in the app_timer case) is initialized and started.

    Best regards,

    Edvin

  • Hi Edvin, thanks for the reply,

    I want to get :

    LastTime=HAL_GetTick();

    /**
      * @brief Provides a tick value in millisecond.
      * @note This function is declared as __weak to be overwritten in case of other 
      *       implementations in user file.
      * @retval tick value
      */
    __weak uint32_t HAL_GetTick(void)
    {
      return uwTick;
    }

    is it equal with LastTime =  nrf_systick_val_get();

    I need to be in ms (mili Second)

    ?

    Test code,

    tick =  nrf_systick_val_get();
    NRF_LOG_INFO("Systick value = %u.\r\n",tick);

    I always get zero, do I miss something ?

    Thanks

  • or , how to use this function ?  nrf_drv_systick_get()     

    nrfx_systick_get(nrfx_systick_state_t * p_state) , what's nrfx_systick_state_t * p_state  ?

    Thanks

  • RixtronixLAB said:

    I want to get :

    LastTime=HAL_GetTick();

     Where is this snippet from?  Where did you find this function?

     

    RixtronixLAB said:
    I always get zero, do I miss something ?

     Yes. You need to start the RTC and the LFCLK. Please see my original answer.

Related