This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cortex-M1/3 SysTick/RTC


> After some more investigation it looks like the SysTick is not THAT  
> usable as the source of the realtime clock. On the STM32, the SysTick  
> cannot be calibrated, and is by default calibrated for 1ms ticks (at  
> maximum system clock frequency). This can be enough for timeslicing but  
> it won't cut it delay_us. The luminary is obviously also pre-calibrated.  
> Do you still think SysTick is a good idea?

The documentation about this is interesting....

http://ecos.sourceware.org/docs-latest/ref/hal-clocks-and-timers.html

There are three main ways of implementating the macro:

   1. a counting loop, typically written in inline assembler, using an
   outer loop for the microseconds and an inner loop that consumes
   approximately 1us. This implementation is automatically thread-safe
   and does not impose any dependencies on the rest of the system, for
   example it does not depend on the system clock having been
   started. However it assumes that the cpu clock speed is known at
   compile-time or can be easily determined at run-time.  

   2. monitor one of the hardware clocks, usually the system
   clock. Usually this clock ticks at a rate independent of the cpu so
   calibration is easier. However the implementation relies on the
   system clock having been started, and assumes that no other code is
   manipulating the clock hardware. There can also be complications
   when the system clock wraps around.

   3. a combination of the previous two. The system clock is used
   during system initialization to determine the cpu clock speed, and
   the result is then used to calibrate a counting loop. This has the
   disadvantage of significantly increasing the system startup time,
   which may be unacceptable to some applications. There are also
   complications if the system startup code normally runs with the
   cache disabled because the instruction cache will greatly affect
   any calibration loop.

SysTick is great for the eCos clock.

You could do a very simple HAL_DELAY_US(us) which only has 1ms
resolution. Not great, but it at least will work and gets you going.

Or you can go for implementation 3, using a 1ms calibration time
derived from the SysTick. 

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]