fix: 修复cortex-m系列系统提供的timer在低频下时间不准的问题
触发场景:
cpu主频比较高,timer频率较低时,当SysTick->VAL == 0时,
触发tick中断,在中断中系统将当前周期累加到基准时间里,在中
断结束更新tick响应时间时,会更新系统基准时间(为了让时间更
加准确)此时由于SysTick->VAL任然等于0,接口HalGetTickCycle
返回的仍然是当前周期,导致该周期被累加了两次。
解决方案:
接口HalGetTickCycle在SysTick->VAL == 0时返回0.
因为SysTick->VAL == 0时,必然会触发tick中断,周期
的累加是由中断处理的,此时只需要返回0即可。
Close #I4HBGR
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Iba6e8799b0ae851fc94aa23867b2360a4245994d
|
||
|---|---|---|
| .gitee | ||
| components | ||
| figures | ||
| kal | ||
| kernel | ||
| targets | ||
| testsuits | ||
| tools | ||
| utils | ||
| .gitignore | ||
| BUILD.gn | ||
| LICENSE | ||
| NOTICE | ||
| OAT.xml | ||
| README.md | ||
| README_zh.md | ||
| arch_spec.md | ||
| arch_spec_zh.md | ||
| config.gni | ||
README.md
LiteOS Cortex-M
Introduction
The OpenHarmony LiteOS Cortex-M is the kernel designed for the lightweight operating system OS for the Internet of Things IoT field. It features small size, low power consumption, and high performance. In addition, it has a simple code structure, including the minimum kernel function set, kernel abstraction layer, optional components, and project directory, and is divided into the hardware-related and hardware-irrelevant layers. The hardware-related layers provide unified hardware abstraction layer HAL interfaces to improve hardware adaptability. The combination and classification of different compilation toolchains and chip architectures meet the requirements of the Artificial Intelligence of Things AIoT field for rich hardware and compilation toolchains. Figure1 shows the architecture of the OpenHarmony LiteOS Cortex-M kernel.
Figure 1 Architecture of OpenHarmony the LiteOS Cortex-M kernel

Directory Structure
The directory structure is listed as below, for the detailed directories, please refer to arch_spec.md.
/kernel/liteos_m
├── components # Optional components
│ ├── backtrace # Backtrace support
│ ├── cppsupport # C++ support
│ ├── cpup # CPU possession (CPUP)
│ ├── dynlink # Dynamic loader & linker
│ ├── exchook # Exception hook
│ ├── fs # File system
│ └── net # Network support
├── kal # Kernel abstraction layer
│ ├── cmsis # CMSIS-compliant API support
│ └── posix # POSIX API support
├── kernel # Minimum function set support
│ ├── arch # Code of the kernel instruction architecture layer
│ │ ├── arm # Code of the ARM32 architecture
│ │ └── include # APIs exposed externally
│ ├── include # APIs exposed externally
│ └── src # Source code of the minimum function set of the kernel
├── targets # Board-level projects
├── utils # Common code
Constraints
Programming languages: C and C++
Currently applicable architectures: Cortex-M3, Cortex-M4, Cortex-M7, and RISC-V
Usage
LiteOS Cortex-M provides projects for three chip architectures, which are located in the targets directory. The methods of compiling and using these projects are as follows:
- Cortex-M3:
The kernel/liteos_m/targets/cortex-m3_stm32f103_simulator_keil directory is the Keil project directory created based on the STM32F103 chip architecture. You can download and install Keil development tools from the Internet. To compile the Cortex-M3 project, go to the cortex-m3_stm32f103_simulator_keil/project directory and double-click the los_demo.uvproj file to open the desired project. After the compilation is successful, burn the file to the corresponding board using JLINK or STM32 ST-LINK Utility.
- Cortex-M4:
The kernel/liteos_m/targets/cortex-m4_stm32f429ig_fire-challenger_iar directory is the IAR project directory created based on the STM32F429IG chip architecture. You can download and install IAR development tools from the Internet. To compile the Cortex-M4 project, go to the cortex-m4_stm32f429ig_fire-challenger_iar/project directory and double-click the los_demo.eww file to open the desired project. After the compilation is successful, burn the file to the corresponding board using JLINK or STM32 ST-LINK Utility.
- Cortex-M7:
The kernel/liteos_m/targets/cortex-m7_nucleo_f767zi_gcc directory is the Makefile project directory created based on the STM32F767ZI chip architecture. The compilation commands are as follows:
cd kernel/liteos_m/targets/cortex-m7_nucleo_f767zi_gcc
make clean; make
After the compilation is successful, the executable file NUCLEO-F767.hex is generated in the cortex-m7_nucleo_f767zi_gcc/build directory. Burn the file to the corresponding board using STM32 ST-LINK Utility.
Repositories Involved
kernel_liteos_m