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

nRF51: is it possible to read the timer counter register?

Is it possible to directly read the timer module counter register in the nRF51?

Parents
  • RTC Counter you CAN read directly, You CANNOT read TIMER counter directly. You need to capture it into one compare register.

    If you are using SDK timer driver

    uint32_t captured_value = current_nrf_drv_timer_capture(instance, cc_channel);
    

    If you are not using driver, then

    NRF_TIMERX->TASKS_CAPTURE[channel_number] = 1;
    uint32_t captured_value = NRF_TIMERx->CC[cc_channel];
    

    @Note: Capturing into CC register means that previous values in those registers are lost. If your application is waiting for some events based on previous values, then your app will malfunction. Capture only into a free CC register.

Reply
  • RTC Counter you CAN read directly, You CANNOT read TIMER counter directly. You need to capture it into one compare register.

    If you are using SDK timer driver

    uint32_t captured_value = current_nrf_drv_timer_capture(instance, cc_channel);
    

    If you are not using driver, then

    NRF_TIMERX->TASKS_CAPTURE[channel_number] = 1;
    uint32_t captured_value = NRF_TIMERx->CC[cc_channel];
    

    @Note: Capturing into CC register means that previous values in those registers are lost. If your application is waiting for some events based on previous values, then your app will malfunction. Capture only into a free CC register.

Children
Related