Re: Adjustable wallclock (get/settimeofday, adjtimex)?
|[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]|
On 2011-06-27, Stanislav Meduna <stano@xxxxxxxxxx> wrote: > On 27.06.2011 16:16, Grant Edwards wrote: > >> When I needed to adjust the time to keep it in sync with a real-time >> clock, I did it at a lower level by adding hooks into the target's HAL >> code that allowed me to gradually slew the cyg_current_time() value by >> adjusting the length of a system tick by small amounts. > > Could you elaborate a bit? Did you change the hardware's interrupt > frequency? Yes. > This would be the best solution, but it depends on how easy the > frequency can be adjusted without disturbing the current running > interval, if at all (e.g. on some hardware the counter reload value > can't be accessed atomically and hitting the wrong values at wrong > time could produce unacceptable clock interrupt jitter). In my case, I was able to change the system tick timer reload value without causing problems. That might be difficult to do on some hardware. For example, you might have to do one (or both) of a couple different "tricks": 1) Stop the timer, change the reload value, then restart the timer with a new value that takes into account the time it was stopped. 2) Check the timer to make sure it's not about to reload. If it's not about to reload, change the reload value. If it is about to reload, wait a bit and try again later. Both of these generally need to be done with interrupts disabled, and are probably best done in assembly language. -- Grant Edwards grant.b.edwards Yow! Where's SANDY DUNCAN? at gmail.com -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss