You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Jiawei Wang <me...@jwang.link.INVALID> on 2025/01/13 13:57:19 UTC
Seeking Guidance on High-Resolution Timer Implementation in NuttX for STM32H7
Hello everyone,
I am currently developing on an STM32H7 board using NuttX and am in need of a high-resolution timer to profile my program.
A timer with microsecond resolution would suffice.
My initial approach was to utilize one of STM32's timers configured in 1MHz auto-reload counter mode, and then combine the counter register value with the SysTick value to derive a time measurement. However, this method feels somewhat hacky and bypasses the OS's abstraction layer, which I prefer to maintain.
As I am relatively new to NuttX, I am unsure of the conventional method within NuttX to achieve this functionality and have not found relevant examples. Any guidance or pointers would be appreciated.
Thank you,
Jiawei Wang <me...@jwang.link>
Re: Seeking Guidance on High-Resolution Timer Implementation in NuttX for STM32H7
Posted by Xiang Xiao <xi...@gmail.com>.
why not use perf count from DWT for performance measurement:
https://github.com/apache/nuttx/blob/master/arch/arm/src/armv7-m/arm_perf.c
On Mon, Jan 13, 2025 at 11:59 PM Roberto Bucher <bu...@gmail.com>
wrote:
> Hi Jiawei Wang
>
> I have a similar requirement. The solution with SysTick and a little
> tick in configuration used through semaphores, doesn't solve the problem
> in a good way: shorter sampling times (<500us) are difficult to obtain,
> in particular in pysimCoder generated code. This is my experience, but
> I'm still waiting for a better solution.
>
> Bye
>
> Roberto
>
>
> On 1/13/25 2:57 PM, Jiawei Wang wrote:
> > Hello everyone,
> >
> > I am currently developing on an STM32H7 board using NuttX and am in need
> of a high-resolution timer to profile my program.
> >
> > A timer with microsecond resolution would suffice.
> >
> > My initial approach was to utilize one of STM32's timers configured in
> 1MHz auto-reload counter mode, and then combine the counter register value
> with the SysTick value to derive a time measurement. However, this method
> feels somewhat hacky and bypasses the OS's abstraction layer, which I
> prefer to maintain.
> >
> > As I am relatively new to NuttX, I am unsure of the conventional method
> within NuttX to achieve this functionality and have not found relevant
> examples. Any guidance or pointers would be appreciated.
> >
> > Thank you,
> >
> > Jiawei Wang <me...@jwang.link>
>
>
Re: Seeking Guidance on High-Resolution Timer Implementation in NuttX for STM32H7
Posted by Roberto Bucher <bu...@gmail.com>.
Hi Jiawei Wang
I have a similar requirement. The solution with SysTick and a little
tick in configuration used through semaphores, doesn't solve the problem
in a good way: shorter sampling times (<500us) are difficult to obtain,
in particular in pysimCoder generated code. This is my experience, but
I'm still waiting for a better solution.
Bye
Roberto
On 1/13/25 2:57 PM, Jiawei Wang wrote:
> Hello everyone,
>
> I am currently developing on an STM32H7 board using NuttX and am in need of a high-resolution timer to profile my program.
>
> A timer with microsecond resolution would suffice.
>
> My initial approach was to utilize one of STM32's timers configured in 1MHz auto-reload counter mode, and then combine the counter register value with the SysTick value to derive a time measurement. However, this method feels somewhat hacky and bypasses the OS's abstraction layer, which I prefer to maintain.
>
> As I am relatively new to NuttX, I am unsure of the conventional method within NuttX to achieve this functionality and have not found relevant examples. Any guidance or pointers would be appreciated.
>
> Thank you,
>
> Jiawei Wang <me...@jwang.link>