Difference between revisions of "OCEOS/oceos kernel/timer"

From wiki
Jump to navigation Jump to search
Line 8: Line 8:
decrements the high order timer when it rolls over, every 71.6 minutes approximately. The 64-bit time range is very long, over 584,000 years.<br>
decrements the high order timer when it rolls over, every 71.6 minutes approximately. The 64-bit time range is very long, over 584,000 years.<br>
The system time is reset to 0 by [[OCEOS/oceos kernel/initialisation#oceos_init()|oceos_init()]].
The system time is reset to 0 by [[OCEOS/oceos kernel/initialisation#oceos_init()|oceos_init()]].
User must define BSP_SYSFREQ. The example can be found in OCEOS demo projects.
<syntaxhighlight lang="C">
#define BSP_SYSFREQ 100
const unsigned int __oceos_bsp_sysfreq = BSP_SYSFREQ * 1000 * 1000;
</syntaxhighlight>
Variable __oceos_bsp_sysfreq  is used by OCEOS to set scaler for timer block.<br>
User must define OCEOS_SYS_TIME_GPTIMER_ADDRESS. It is start address of timer unit.
<syntaxhighlight lang="C">
#define OCEOS_SYS_TIME_GPTIMER_ADDRESS          0x80003000
const U32_t __oceos_bsp_sys_time_handler = OCEOS_SYS_TIME_GPTIMER_ADDRESS;
</syntaxhighlight>
__oceos_bsp_sys_time_handler is used by OCEOS to configure two timers to be used for system time.<br>
Timer index in Timer unit start from 1. In timer chain, timer with smaller index is timer lowest, decrements to zero and then decrement the timer highest.
User must specify index of timer highest in timer unit. This must be 2 or higher, depends on number of timers in timer unit. In the case where the index is 2, timer lowest is index 1 and timer highest is index 2.
<syntaxhighlight lang="C">
#define SYS_TIME_TIMER_INDEX                    2  // System time is using two chained timers. This index is higher timer index
...
/*
  * Create the application configuration structure
  */
struct application_configuration          app_config = {0};
app_config.sys_time_timer_index          = SYS_TIME_TIMER_INDEX;          // 0 => invalid index
</syntaxhighlight>


==== <span style="color:#0000ff">ARM Cortex-M</span> ====
==== <span style="color:#0000ff">ARM Cortex-M</span> ====


[[Category:backup]]
[[Category:backup]]

Revision as of 12:40, 16 March 2022

OCEOS System Time

Introduction

SPARC

In OCEOS for SPARC system time is based on two chained 32-bit timers.
No interrupts are involved, the current system time is obtained by reading the two timer counter registers (in an atomic way) and then inverting the values since the timers count down.
The scaler associated with the timers is configured based on the system clock frequency to decrement the low order timer every microsecond. This decrements the high order timer when it rolls over, every 71.6 minutes approximately. The 64-bit time range is very long, over 584,000 years.
The system time is reset to 0 by oceos_init().

User must define BSP_SYSFREQ. The example can be found in OCEOS demo projects.

#define BSP_SYSFREQ 100 
const unsigned int __oceos_bsp_sysfreq = BSP_SYSFREQ * 1000 * 1000;

Variable __oceos_bsp_sysfreq is used by OCEOS to set scaler for timer block.
User must define OCEOS_SYS_TIME_GPTIMER_ADDRESS. It is start address of timer unit.

#define OCEOS_SYS_TIME_GPTIMER_ADDRESS          0x80003000 
const U32_t __oceos_bsp_sys_time_handler = OCEOS_SYS_TIME_GPTIMER_ADDRESS;

__oceos_bsp_sys_time_handler is used by OCEOS to configure two timers to be used for system time.
Timer index in Timer unit start from 1. In timer chain, timer with smaller index is timer lowest, decrements to zero and then decrement the timer highest. User must specify index of timer highest in timer unit. This must be 2 or higher, depends on number of timers in timer unit. In the case where the index is 2, timer lowest is index 1 and timer highest is index 2.

#define SYS_TIME_TIMER_INDEX                    2  // System time is using two chained timers. This index is higher timer index
...
 /*
  * Create the application configuration structure
  */
struct application_configuration           app_config = {0};
app_config.sys_time_timer_index          = SYS_TIME_TIMER_INDEX;          // 0 => invalid index

ARM Cortex-M