micros() Resolution

All about boards manufactured by ST
Post Reply
Ali
Posts: 1
Joined: Tue Feb 23, 2021 11:24 am

micros() Resolution

Post by Ali »

Hello:

Is there any way to know the resolution of micros() for the Arduino Portenta H7 (which employs STM32H747)? I have checked for other boards e.g. Arduino Nano which is mentioned as 4 uS. However, I couldn't find one for Portenta H7.

Is there any way to measure or look for that
Ollie
Posts: 6
Joined: Wed Mar 18, 2020 4:46 am

Re: micros() Resolution

Post by Ollie »

I am not aware of the H7 Arduino library implementation. You should get 1 us resolution. If you need 5 nanosecond resolution (with 400 MHz clock) then you can use the following two macros

Code: Select all

#define initCycleCounter() \
    CoreDebug->DEMCR   |= CoreDebug_DEMCR_TRCENA_Msk; \
    DWT->CYCCNT         = 0; \
    DWT->CTRL          |= DWT_CTRL_CYCCNTENA_Msk


#define readCycleCounter()  (DWT->CYCCNT)
These macros do work on all STM32 processors and I have been using them for many years.
Edogaldo
Posts: 10
Joined: Fri Jul 10, 2020 10:11 pm

Re: micros() Resolution

Post by Edogaldo »

@Ali I think here is your answer: https://www.arduino.cc/reference/en/lan ... me/micros/
[...]
On the boards from the Arduino Portenta family this function has a resolution of one microsecond on all cores.
[...]
Post Reply

Return to “STM boards (Discovery, Eval, Nucleo, ...)”