Timers. STMicroelectronics ST40
Annons
Annons
OS21, ST40
1 Timers
Timers
The ST40 has three independent timer units (TMUs). Each is capable of running as a free running auto-reload 32-bit counter, with interrupt on underflow. Each can be programmed to count either the RTC (16 kHz) or some fraction of the input clock. The greatest accuracy is obtained by counting based on a large fraction of the input clock, and running that clock at a high frequency.
1.3
1.4
Note:
The precise speed of the input clock is determined by the end user; it is a function of the board design and boot software. OS21 is not responsible for setting the input speed, therefore it has to be made aware of what it is.
This is done with the Board Support Package (BSP) using a function called bsp_timer_input_clock_frequency_hz()
. Full details of this function can be found in the OS21 User manual (ADCS 7358306), chapter 16.
OS21 tick duration
OS21 establishes the period of one tick when it boots. Based on the input clock frequency it selects an appropriate divisor to yield a tick which is approximately 10 microseconds.
ST40 timer assignments
OS21 uses all three ST40 TMU timers, as shown in
.
Table 1.
ST40 timer assignments
Timer name OS21 usage
TMU0
TMU1
TMU2
System timer
Timeslice timer
Timeout timer
The system timer is left free running and is used by time_now()
to return the system time.
On ST40, the system time ( osclock_t
) is a 64-bit value. OS21 maintains the top 32 bits of the 64-bit time using an interrupt handler which is called each time the 32-bit timer reaches zero. The lower 32 bits of the system time are the value in the system timer.
The timeslice timer is programmed to run for the timeslice period before generating an interrupt and reloading. This is used to drive timeslice events into the task scheduler.
When profiling (the application is built with the
-pg
flag), this timer is used for PC sampling as well as timeslicing. In this case, it is programmed to yield approximately 16384 interrupts per second. OS21 ensures that the frequency of timeslice events into the scheduler remains unchanged.
7358673 5/23
Timers OS21, ST40
The timeout timer is programmed on demand to interrupt when the required number of ticks has elapsed. When multiple timeouts are requested, OS21 orders which timeout should occur next, and programs the timeout timer appropriately.
6/23 7358673
Ladda ner
Annons