This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

error: DWT implements no cycle counter. Cannot be used for cycle counting.

Hello, I tried to implement the zephyr executing time functions API on my nrf52 hardware and I got the above error. According to my SoC documentation (nRF52833), this hardware does include a DWT counter. I am not sure if I need to do anything special to configure this hardware or if I need to use a relevant nrfx driver. My code was very similar to the example code in the zephyr documentation mentioned here https://docs.zephyrproject.org/latest/reference/timing_functions/index.html. Any inputs? Thx!

  • Hi,

    Try setting this in prj.conf:

    CONFIG_TIMING_FUNCTIONS=y

  • I already have this config statement in my proj.conf.

  • Hi,

    Here is my project, I used NCS v1.5.0, and I'm not able to re-create this when building for board nrf52833dk_nrf52833

    timing.zip

    If you are not using nrf52833dk_nrf52833 , then it might be an issue with your board files.

  • Hello,

    I'm experiencing exactly the same problem using nrf52840 DK (PCA10056).

    If I set CONFIG_TIMING_FUNCTIONS=y, by default the Timing Zephyr subsystem will pick the architecture-dependent implementation (arch_).

    So, when invoking timing_init, this function in zephyr\arch\arm\include\aarch32\cortex_m\dwt.h will be invoked:

    /**
     * @brief Initialize and Enable the DWT cycle counter
     *
     * This routine enables the cycle counter and initializes its value to zero.
     *
     * @return 0
     */
    static inline int z_arm_dwt_init_cycle_counter(void)
    {
    	/* Clear and enable the cycle counter */
    	DWT->CYCCNT = 0;
    	DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
    
    	/* Assert that the cycle counter is indeed implemented. */
    	__ASSERT((DWT->CTRL & DWT_CTRL_NOCYCCNT_Msk) != 0,
    		"DWT implements no cycle counter. "
    		"Cannot be used for cycle counting\n");
    
    	return 0;
    }

    And contextually, the assert is triggered.

    I think this is easily reproducible, I'm using a standard dev kit atm.
    I don't have any other board to use with the same chip, but I don't see any reason why it would mean that this board is faulty...

    Can anybody try to confirm this?
    It maybe a timing issue in the asserting condition.

    Note: I initially wondered why a benchmark sample (latency measure) was working fine measuring time with DWT. I then realised that asserts are just disabled in the sample...

    ...
    CONFIG_FORCE_NO_ASSERT=y
    ...

    Thanks in advance for your help!

    D

Related