This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: ecos and gettimeofday()
>>>>> "Peter" == Peter Korsgaard <jacmet@sunsite.dk> writes:
Peter> If the problem is that you don't know if the clock DSR has run or not,
Peter> perhaps you could do something hackish like this to make sure
Peter> it hasn't:
No, this also doesn't work.
We want to be able to do a HAL_CLOCK_READ() and cyg_current_time() and
want the two values to be in sync. When HAL_CLOCK_READ() reaches
CYGNUM_HAL_RTC_PERIOD an interrupt is generated and the clock is reset
to 0. The DSR will then at some later time be executed and
cyg_current_time() incremented.
If cyg_current_time() was updated in the ISR my routine would work.
What we need to detect is the case of a HAL_CLOCK_READ overflow
(interrupt) having occurred, but the DSR not executed yet. This can be
done by:
1) Updating the counter in the ISR and use that for cyg_current_time()
(it still needs to be done in the DSR for alarms as well).
2) Set a flag in the ISR that the DSR is pending, clear it in the
DSR. Increment cyg_current_time if it's set. Alternatively use the
dsr_count from Cyg_interrupt.
Which of these would be preferred? Or is there a cleaner solution?
--
Bye, Peter Korsgaard
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss