3

Is there any way to know the resolution of micros() for the Arduino Portenta H7. I have checked for other boards e.g. 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

RowanP
  • 819
  • 4
  • 21
Basit Ali
  • 63
  • 4
  • Maybe grab the value in a tight loop and compute the shortest difference you find? – PMF Feb 23 '21 at 12:21
  • @PMF: That would only give an upper boundary: the resolution could conceivably be smaller than the time taken by a loop iteration. – Edgar Bonet Feb 23 '21 at 13:50
  • I agree, but it would be a first hint. – PMF Feb 23 '21 at 16:02
  • 2
    A Protenta is completely different from a standard AVR Arduino. It is built with a M7/M4 dual core ARM mcu running on 480/240 MHz. There is also an OS installed on the board (mbed OS). The sketches run on top of this OS. I don't know the actuall status but ~2015 (?) I followed a discussion about using a 'millis()' resolution of 50µs Arduino_mbed core. Unbelievable I know, but the reason was: The OS runs tasks and a timer irq with a call frequency of a MHz would slow down the scheduler and the tasks. – Peter Paul Kiefer Feb 23 '21 at 18:46
  • 1
    So the discussion was seriously about a 50µs resolution that leads to 20kHz Timer IRQs. I'm not sure if this is still the truth. But if they still use a 50µs resolution you could follow the idea of @PMF and see if the difference between two `micros()` calls is dividable by 50 or 30 or whatever. – Peter Paul Kiefer Feb 23 '21 at 18:47
  • I did some measurements today. I used digital pins of the board to ON and OFF during each analogRead call for ADC. These digital pins are then connected to the Oscilloscope. Also, I used the micro() before and after the analogRead in my sketch to measure the time from the board. I obtained approximately 4uS time which it takes to execute one analogRead(), using an Oscilloscope. However, the micros() function of the board couldn't give me that value. So it was showing the same time before and after the analogRead call. – Basit Ali Feb 25 '21 at 07:32
  • Then, I called analogRead multiple times to increase the execution time and found that the maximum resolution I could obtain using micros() was around 32uS. This is inferior to the ordinary Arduino board even. – Basit Ali Feb 25 '21 at 07:33
  • The question was cross posted to Arduino forum where user sbhklr asserted that the resolution was 1uS without providing any reasoning or references. https://forum.arduino.cc/t/micros-resolution-for-arduino-portenta-h7/697386 – RowanP Feb 15 '22 at 10:18
  • The question was cross posted to Arduino for STM32 forum, with some success. https://www.stm32duino.com/viewtopic.php?t=934 User edogaldo quoted Arduino doco in support of the 1uS answer. https://www.arduino.cc/reference/en/language/functions/time/micros/ – RowanP Feb 15 '22 at 10:24

1 Answers1

1

The micros() language reference states that, "[The micros() function] returns the number of microseconds since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 70 minutes. On the boards from the Arduino Portenta family this function has a resolution of one microsecond on all cores. On 16 MHz Arduino boards (e.g. Duemilanove and Nano), this function has a resolution of four microseconds (i.e. the value returned is always a multiple of four). On 8 MHz Arduino boards (e.g. the LilyPad), this function has a resolution of eight microseconds.

It seems likely that the doco was updated some time after the OP posted the question.

RowanP
  • 819
  • 4
  • 21