SiFli Solution is now fully open: a production-ready solution set that accelerates projects from prototype to mass production. Solution Documentation.

SiFli-Wiki SiFli-Wiki SiFli-Wiki
  • User Guide
  • Examples
  • API Documentation
  • About Us
/
  • English
  • 中文

Quick Start

  • Getting Started
  • Product Documentation Summary

Software Development

  • SDK Programming Guide
  • API Documentation
  • Solution Programming Guide
  • FAQ Frequently Asked Questions
    • Development Tool-Related Issues
      • 1 Compilation-Related
      • 2 Jlink
      • 3 KEIL
      • 4 Ozone
      • 5 SiFli
      • 6 Trace32
      • 7 SystemView
      • 8 UART
      • 9 Source Insight-related
    • Chip-Related Issues
      • 1 GPIO-related
      • 2 Timer-Related
      • 3 Interrupt-related
      • 4 Watchdog-Related
      • 5 RTC Related
      • 6 ADC Related
      • 7 I2C-related
      • 8 Low Power-Related
      • 9 PWM
      • 10 System
      • 11 Bluetooth
      • 12 USB-Related
      • 13 UART-Related
      • 14 Dual-core Related
      • 15 I2S-related
      • 13 SPI Related Issues
    • Peripheral Driver Debugging Issues
      • 1 Common LCD Debugging Issues
      • 2 Common Sensor Debugging Issues
      • 3 Common Flash Debugging Issues
      • 4 Common Motor Debugging Issues
    • Software Debugging-Related Issues
      • 1 Log Debugging
      • 2 Online Debugging Method
      • 3 Restoring the Crash Context from a Memory Dump
      • 4 Methods for Saving the Crash Context
  • Application Notes
    • Low-Power Development Guide
    • Application Startup Flow
    • NandFlash_BBM Analysis Guide
    • SF32LB52-DevKit-Core-3p3 Development Board Test Guide
  • Best Practices
    • AI Xiaozhi

Hardware Development

  • SiFli Selection Guide
    • SiFli Chip Model Guide
    • Module Model Guide
  • Chip Hardware Design Guide
    • SF32LB52x Hardware Design Guide
    • SF32LB52X Hardware Design Guide
    • SF32LB56xU Hardware Design Guide
    • SF32LB56xV Hardware Design Guide
    • SF32LB58x Hardware Design Guide
    • SF32 Series UART Automatic Flashing Design
    • SF32LB55x Hardware Design Guide
    • SF32LB52-MOD-1 Module EPD Display Design Guide
  • Development board
    • Development Board Model Guide
    • SF32LB52-DevKit-LCD Development Board User Guide
    • Guide to Making an LCM Adapter Board for SiFli Development Boards
    • Lichuang Huangshan Pi Development Board User Guide
    • SF32LB52-DevKit-Nano Development Board User Guide
    • SF32LB52-DevKit-Core-3p3 Development Board User Guide
    • SF32LB52-OED-6’-EPD Development Board User Guide
    • SF32LB56-DevKit-LCD Development Board User Guide
    • SF32LB58-DevKit-LCD Development Board User Guide
  • Module

Software Tools

  • Software and Hardware Tool Summary
    • Firmware flashing tool Impeller
    • Graphics Conversion Tool
    • Storage debugging tools
      • Flash Chipid and Type Configuration Guide
    • Screen module debugging
      • Screen module introduction
      • Display module framework introduction
      • Directory structure introduction
        • External
        • Built-in
      • Add display module (1) – Add files (copy files)
      • Add display module (2) – Modify the copied driver files
        • Modify the screen driver
        • Modify the screen TP driver
        • Modify the screen backlight driver
      • Add display module (3) – Modify Kconfig/Menuconfig
      • Example operations for adding a display module
        • SF32LB52x-DevKit-LCD example: adding an SPI-LCD (external)
        • Example: adding a QSPI-LCD on 525 (built-in)
        • Example: adding a DPI-LCD on 566 (built-in)
      • FAQ
      • Appendix
        • Display driver callback functions
        • Mapping table between application-layer functions and module driver-layer functions
        • List of adapted display modules
      • LCD frame-rate calculator
    • sftool

Product Introduction

  • About SiFli

On this page

  • 2.1 Delay Functions
  • 2.2 Obtaining the Timestamp, Tick Value, and RC10K Oscillation Frequency
  • 2.3 Serial Port Command for Viewing Existing Timers
SiFli-Wiki 0 0
Edit this page
  1. SiFli-Wiki /
  2. FAQ Frequently Asked Questions /
  3. Chip-Related Issues /
  4. 2 Timer-Related
View as Markdown Open in ChatGPT Open in Claude

2 Timer-Related¶

2.1 Delay Functions¶

  1. HAL-layer delay function: (equivalent to an instruction loop in a while loop; it does not switch to other threads during the delay)

HAL_Delay(10); /* 延时10ms */
HAL_Delay_us(10); /* 延时10us */
  1. RTT interface delay function:
    When the RTT interface delay function executes, it switches to other threads, such as the ilde thread. When the sleep threshold is lower than the delay duration, it will enter Standby sleep.

rt_thread_delay(100); /* 延时100ms */

2.2 Obtaining the Timestamp, Tick Value, and RC10K Oscillation Frequency¶

  1. Obtain the timestamp:

/* 32768晶体时钟,会1/32768秒,寄存器值加1*/
/* RC10K时钟,会约1/9000秒,寄存器值加1*/
uint32_t start_time = HAL_GTIMER_READ(); 
  1. Obtain the Tick value that increments every 1 ms:

rt_tick_t start_timer = rt_tick_get(); /* RTT系统函数,1m秒返回值会加1 */
uint32_t tickstart = HAL_GetTick();  /* HAL层的函数,1m秒返回值会加1 */
  1. Obtain the current clock frequency:

/* 32768晶体时钟,会返回32768*/
/* RC10K时钟,会返回8k-10k之间的值*/
uint32_t mcuOscData = HAL_LPTIM_GetFreq(); 

2.3 Serial Port Command for Viewing Existing Timers¶

list_timer


alt text
Description of the list_timer status:
The first column, “timer”, is the timer name;
The second column, “periodic”, is the timer period (hexadecimal, in ms);
The third column, “timeout”, is the timestamp when the next timer expires;
The fourth column, “flag”, indicates whether the timer is active,
As shown in the figure above, the only active timer is the “main” timer (the delay function is also a timer), and the wake-up period is 0xbb8 (3000ms).

Previous
1 GPIO-related
Next
3 Interrupt-related

2025, SiFli

Made with Sphinx and Shibuya theme.