Re: Sleep Resolution

2021-03-25 Thread Arie de Muijnck
y). Then I thought a proper function would be better but got stuck in that expression "sleep resolution" For that scale (10 SYSCLK cycles), a loop is probably OK but I wanted to make sure there's not a more appropriate system tool El mié, 24 mar 2021 a las 10:46, Sara d

Re: Sleep Resolution

2021-03-25 Thread Nathan Hartman
On Thu, Mar 25, 2021 at 2:22 PM Grr wrote: > > 1nsec means 1GHz, it is very hard to achieve the required accuracy even > > with the high end CPU. But since the standard defines nano_sleep, > up_ndelay > > looks not so unreasonable. > > > > I don't mean 1 ns > > I mean delays in the order of _doze

Re: Sleep Resolution

2021-03-25 Thread Grr
> 1nsec means 1GHz, it is very hard to achieve the required accuracy even > with the high end CPU. But since the standard defines nano_sleep, up_ndelay > looks not so unreasonable. > I don't mean 1 ns I mean delays in the order of _dozens_ of ns 100 MHz (a very reasonable frequency nowadays) mea

Re: Sleep Resolution

2021-03-25 Thread Xiang Xiao
On Thu, Mar 25, 2021 at 5:25 AM Grr wrote: > Why not use msec & usec delays? > > Because the need is nsec delays > > Ok, I understand. > My question is: > > Why not add a portable, general purpose nsec delay function to Nuttx? > > 1nsec means 1GHz, it is very hard to achieve the required accura

Re: Sleep Resolution

2021-03-25 Thread Grr
Why not use msec & usec delays? Because the need is nsec delays My question is: Why not add a portable, general purpose nsec delay function to Nuttx? El mié, 24 mar 2021 a las 22:34, Xiang Xiao () escribió: > Another way to avoid the calibration is to reuse the hardware timer in the > busy loo

Re: Sleep Resolution

2021-03-24 Thread Xiang Xiao
Another way to avoid the calibration is to reuse the hardware timer in the busy loop: https://github.com/apache/incubator-nuttx/blob/master/drivers/timers/arch_alarm.c#L60-L74 https://github.com/apache/incubator-nuttx/blob/master/drivers/timers/arch_timer.c#L122-L144 On Thu, Mar 25, 2021 at 11:42

Re: Sleep Resolution

2021-03-24 Thread Gregory Nutt
Why not call up_udelay or up_mdelay? The arch/soc should provide a best implementation for you. I was wondering that too. Also, as a side note, it is very important to calibrate the delay loop using in those functions.  If the delay loop is properly calibrated, these can be very accurate (

Re: Sleep Resolution

2021-03-24 Thread Xiang Xiao
general solution for this problem to > the > > Nuttx toolbox > > > > El mié, 24 mar 2021 a las 11:24, David Sidrane ( >) > > escribió: > > > > > What HW is this on? > > > > > > -Original Message- > > > From: Grr [mail

Re: Sleep Resolution

2021-03-24 Thread Nathan Hartman
On Wed, Mar 24, 2021 at 4:49 PM Grr wrote: > > Since afterstart = 0, there should be no loop to optimize out except ONE > value test > > One hundred cycles for that would seem excessive for me > > TWENTY THOUSAND CYCLES for a _zero_ loop?!? > > Maybe in Java We didn't see the value of transfer->d

Re: Sleep Resolution

2021-03-24 Thread Grr
for(delay = 0; delay < transfer->dev->afterstart; delay++); afterstart is loop's limit, which determines the desired delay length, known by definition El mié, 24 mar 2021 a las 14:57, Johnny Billquist () escribió: > Well. There was nothing in there that showed me that afterstart == 0. Is > this

Re: Sleep Resolution

2021-03-24 Thread Johnny Billquist
Well. There was nothing in there that showed me that afterstart == 0. Is this a known fact, or an assumption? Johnny On 2021-03-24 21:47, Grr wrote: Since afterstart = 0, there should be no loop to optimize out except ONE value test One hundred cycles for that would seem excessive for me T

Re: Sleep Resolution

2021-03-24 Thread Grr
Since afterstart = 0, there should be no loop to optimize out except ONE value test One hundred cycles for that would seem excessive for me TWENTY THOUSAND CYCLES for a _zero_ loop?!? Maybe in Java El mié, 24 mar 2021 a las 14:30, Gregory Nutt () escribió: > > > Weird behavior: > > > > Simpl

Re: Sleep Resolution

2021-03-24 Thread Gregory Nutt
Weird behavior: Simply changing loop counter variable from uint16_t to volatile uint16_t causes initial delay (with variable delay = 0) going from ~500 ns to ~120 us The code is uint16_t delay; select_function(); for(delay = 0; delay < transfer->dev->afterstart; delay++); Any ideas? I ima

Re: Sleep Resolution

2021-03-24 Thread Nathan Hartman
On Wed, Mar 24, 2021 at 3:53 PM Johnny Billquist wrote: > > Perfectly expected. > With volatile, the compiler are not allowed to optimize away the memory > accesses for updating the loop variable. So you are suddenly getting a > lot of memory read/write cycles that probably didn't happen before. >

Re: Sleep Resolution

2021-03-24 Thread Johnny Billquist
r. I started by an empty for loop but it seems optimization gets rid of it (I haven't researched the issue properly). Then I thought a proper function would be better but got stuck in that expression "sleep resolution" Add volatile to the loop counter variable an

Re: Sleep Resolution

2021-03-24 Thread Grr
seems optimization gets rid of it > (I > > haven't researched the issue properly). Then I thought a proper function > > would be better but got stuck in that expression "sleep resolution" > > Add volatile to the loop counter variable and the optimizer will not > remove it. > > >

Re: Sleep Resolution

2021-03-24 Thread Gregory Nutt
Is the Tickless mode considered stable enough for production use now? IIRC it had some caveats when I last looked into it and I haven't had a chance to study it again. I believe so.  I am not aware of any issues.  It has been around for several years and has been used by a lot of NuttX users. 

Re: Sleep Resolution

2021-03-24 Thread Nathan Hartman
On Wed, Mar 24, 2021 at 2:53 PM Gregory Nutt wrote: > > > > The way the logic in clock_nanosleep() is written, the minimum delay > > ends up being 2 such ticks. I don't remember why and I can't seem to > > find it in the code right now, but I know this because I checked into > > it recently and fo

Re: Sleep Resolution

2021-03-24 Thread Gregory Nutt
The way the logic in clock_nanosleep() is written, the minimum delay ends up being 2 such ticks. I don't remember why and I can't seem to find it in the code right now, but I know this because I checked into it recently and found out that that's how it works. See https://cwiki.apache.org/conf

Re: Sleep Resolution

2021-03-24 Thread Nathan Hartman
is rounded up to an integer multiple of the > sleep resolution" > > What is the sleep resolution and where/how is defined? I'm a little late to the party, but... The resolution would likely be 20 milliseconds, which is far more than you want. Here's how I get that 20

Re: Sleep Resolution

2021-03-24 Thread Gregory Nutt
t a proper function would be better but got stuck in that expression "sleep resolution" Add volatile to the loop counter variable and the optimizer will not remove it.

RE: Sleep Resolution

2021-03-24 Thread David Sidrane
. David -Original Message- From: Grr [mailto:gebbe...@gmail.com] Sent: Wednesday, March 24, 2021 10:52 AM To: dev@nuttx.apache.org Subject: Re: Sleep Resolution This is a SocketCAN driver for MCP2515 with a new SPI system that streamlines the select->write->read->deselect proce

Re: Sleep Resolution

2021-03-24 Thread Fotis Panagiotopoulos
1 a las 11:24, David Sidrane () > escribió: > > > What HW is this on? > > > > -Original Message- > > From: Grr [mailto:gebbe...@gmail.com] > > Sent: Wednesday, March 24, 2021 10:09 AM > > To: dev@nuttx.apache.org > > Subject: Re: Sleep Resolution > &g

Re: Sleep Resolution

2021-03-24 Thread Grr
uttx toolbox El mié, 24 mar 2021 a las 11:24, David Sidrane () escribió: > What HW is this on? > > -Original Message- > From: Grr [mailto:gebbe...@gmail.com] > Sent: Wednesday, March 24, 2021 10:09 AM > To: dev@nuttx.apache.org > Subject: Re: Sleep Resolution > >

Re: Sleep Resolution

2021-03-24 Thread Barbiani
, 2021 10:09 AM > To: dev@nuttx.apache.org > Subject: Re: Sleep Resolution > > Thank you very much for your response > > What I'm trying to do is to generate hold and disable times for SPI CS, > which should be about 50 ns > > I started by an empty for loop but it

RE: Sleep Resolution

2021-03-24 Thread David Sidrane
What HW is this on? -Original Message- From: Grr [mailto:gebbe...@gmail.com] Sent: Wednesday, March 24, 2021 10:09 AM To: dev@nuttx.apache.org Subject: Re: Sleep Resolution Thank you very much for your response What I'm trying to do is to generate hold and disable times for S

RE: Sleep Resolution

2021-03-24 Thread David Sidrane
Subject: Sleep Resolution Hello to all. Looking for the right way to create a _very_ short delay (10-100 ns), I found clock_nanosleep, whose description says: "The suspension time caused by this function may be longer than requested because the argument value is rounded up to an integer multiple o

Re: Sleep Resolution

2021-03-24 Thread Alan Carvalho de Assis
I > found clock_nanosleep, whose description says: > > "The suspension time caused by this function may be longer than requested > because the argument value is rounded up to an integer multiple of the > sleep resolution" > > What is the sleep resolution and where/how is defined? > > TIA > Grr >

Re: Sleep Resolution

2021-03-24 Thread Grr
n would be better but got stuck in that expression "sleep resolution" For that scale (10 SYSCLK cycles), a loop is probably OK but I wanted to make sure there's not a more appropriate system tool El mié, 24 mar 2021 a las 10:46, Sara da Cunha Monteiro de Souza (< saramonteiro

Re: Sleep Resolution

2021-03-24 Thread Sara da Cunha Monteiro de Souza
ion time caused by this function may be longer than requested > because the argument value is rounded up to an integer multiple of the > sleep resolution" > > What is the sleep resolution and where/how is defined? > > TIA > Grr >

Sleep Resolution

2021-03-24 Thread Grr
Hello to all. Looking for the right way to create a _very_ short delay (10-100 ns), I found clock_nanosleep, whose description says: "The suspension time caused by this function may be longer than requested because the argument value is rounded up to an integer multiple of the sleep resol