TSI Timer Features

Introduction

The types of timers supported by the TLSR8258 are as follows:

  • System Timer: the clock frequency for System Timer is fixed as 16Mhz,irrespective of system clock
  • Timer0/Timer1: general timer is provided for user, it supports 4 modes:
    • System Clock Mode: After Timer is enabled, Timer Tick is incerased by 1 on each positive edge of system clock from initial Tick value.
    • GPIO Trigger Mode: Timer Tick is increased by 1 on each positive or negative (configurable) edge of GPIO from initial Tick value
    • GPIO Pulse width Mode: system clock is employed as the unit to measure the width of GPIO pulse.
    • Tick Mode: After Timer is enabled, Timer Tick starts counting upward, and Timer Tick value is increased by 1 on each positive edge of system clock.
  • Timer2: Support all 4 modes above. Besides, Timer2 supports Watchdog, which could reset chip from unexpected hang up or malfunction.
  • 32K Timer: This timer can be used as one kind of wakeup source to wake up MCU from deepsleep mode or suspend mode.

System Timer

The TLSR8258F512 also supports a System Timer. System Timer clock is derived from 24M cystal oscillator via a 2/3 frequency divider. The clock frequency is fixed as 16Mhz. The relative APIs refer to APIs list

Timer0/1/2

The TLSR8258F512 supports three timers: Timer0 ~ Timer2. The three timers all support four modes. The clock source of all three timers is System Clock.

Since these modes are relatively simple, we provide examples to make it easy for users to use directly.

Watchdog

Programmable watchdog could reset chip from unexpected hang up or malfunction. But only Timer2 supports Watchdog.

Chip will be reset when the Timer2 Tick matches Watchdog capture. It is noted that Timer2 Tick has 32 bits, but Watchdog Capture has only 14bits.

32K Timer

The TLSR8258F512 also supports a low frequency (32KHz) Timer in suspend mode or deepsleep mode. The clock source of 32K Timer is 32KHz RC Oscillator or 32KHz Crystal Oscillator, which is configurable. This timer can be used as one kind of wakeup source. For more details ...

Timer APIs List

In order to facilitate users to quickly develop products according to their own needs, TSI provide the following related APIs and examples.

APIs list Description Example Update Date Status
sleep_us() delay by microsecond - 2019-1-10 Done
sleep_ms() delay by millisecond - 2019-1-10 Done
clock_time_exceed() time out by microsecond - 2019-1-10 Done
clock_time() get tick value of system timer - 2019-1-10 Done
timer0_gpio_init() set the polarity of gpio for GPIO Trigger Mode or GPIO Pulse Width Mode of Timer0 refer to API-TIMER-CASE2 2019-1-10 Done
timer1_gpio_init() set the polarity of gpio for GPIO Trigger Mode or GPIO Pulse Width Mode of Timer1 refer to API-TIMER-CASE2 2019-1-10 Done
timer2_gpio_init() set the polarity of gpio for GPIO Trigger Mode or GPIO Pulse Width Mode of Timer2 API-TIMER-CASE2 2019-1-10 Done
timer0_set_mode() set the mode of Timer0 , the initial tick and the capture tick refer to API-TIMER-CASE1 2019-1-10 Done
timer1_set_mode() set the mode of Timer1 , the initial tick and the capture tick refer to API-TIMER-CASE1 2019-1-10 Done
timer2_set_mode() set the mode of Timer2 , the initial tick and the capture tick API-TIMER-CASE1 2019-1-10 Done
timer_start() get tick value of system timer API-TIMER-CASE1 2019-1-10 Done
timer_stop() get tick value of system timer - 2019-1-10 Done

APIs related to Watchdog are listed below.

APIs list Description Example Update Date Status
wd_set_interval_ms() set the interval of watchdog by millisecond API-TIMER-CASE5 2019-1-10 Done
wd_clear() clear the tick for watchdog API-TIMER-CASE5 2019-1-10 Done
wd_start() start watchdog API-TIMER-CASE5 2019-1-10 Done
wd_stop() stop watchdog - 2019-1-10 Done

TSI provides the following examples of this module to help users quickly understand and apply related modules.

Examples list Description Update Date Status
API-TIMER-CASE1 Timer in system clock Mode 2019-1-10 Done
API-TIMER-CASE2 Timer in GPIO Trigger Mode 2019-1-10 Done
API-TIMER-CASE3 Timer in GPIO Pulse Width Mode 2019-1-10 Done
API-TIMER-CASE4 Timer in Tick Mode 2019-1-10 Done
API-TIMER-CASE5 watch dog mode 2019-1-10 Done

History Record

Date Description Author
2019-1-10 initial release LJW
2019-8-15 update api name for application LJW