Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of interrupt priority setting in SylixOS Lite version

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you the SylixOS Lite version of the interrupt priority setting example analysis, I hope you will learn something after reading this article, let's discuss it together!

1. Non-Lite version interrupt shutdown mode

SylixOS provides the user with the interface for arch layer gateway interrupts, whose interface name is archIntDisable (). Calling this function will disable interrupts for all peripherals.

In the ARM architecture, for ARM series and Cortex-A series chips, the arch layer interface archIntDisable () is implemented as shown in listing 1.1.

Listing 1.1 the arch layer interrupt shutdown mode for the non-Lite version

FUNC_DEF (archIntDisable) MRS R0, CPSR ORR R1, R0, # 0x80 MSR CPSR_c, R1 MRS R2, CPSR AND R2, # 0x80 CMP R2, # 0x80 BNE archIntDisable BX LR FUNC_END ()

The above code is implemented by assembly language, and it can be seen that the archIntDisable function mainly shields all interrupts by changing the interrupt disability position 1 in the CPSR register.

2.Lite version interrupt shutdown mode

However, in the chips of ARM Cortex-M and Cortex-A series, there is no CPSR register. It provides BASEPRI interrupt mask register. SylixOS uses interrupt priority to mask arch layer interrupts. The implementation of its archIntDisable interface is shown in listing 2.1of the program.

Listing 2.1 Lite version of the arch layer interrupt shutdown mode

FUNC_DEF (archIntDisable) MRS R0, BASEPRI MOV R1, # LW_CFG_CORTEX_M_INT_MASK MSR BASEPRI, R1 BX LR FUNC_END ()

In the Lite version, the interrupt of the arch layer is masked according to the interrupt priority mask. The macro definition LW_CFG_CORTEX_M_INT_MASK represents the interrupt priority mask, and SylixOS is set to 2 by default, that is, when the archIntDisable function is called, the interrupt number with interrupt priority greater than 2 will be masked, and the interrupt number with interrupt priority less than 2 will not be shielded.

Therefore, in the Lite version of BSP, it is necessary to set the interrupt priority of each peripheral device to greater than 2, so that all interrupts can be turned off, otherwise SylixOS may cause errors because some peripheral interrupts cannot be closed at some key code that needs to turn off interrupts.

The interface definition for setting the interrupt priority of the peripheral is shown in listing 2.2, and each driver peripheral can be set according to the actual situation.

Listing 2.2 sets the interrupt priority function

# include ULONG API_InterVectorSetPriority (ULONG ulVector, UINT uiPrio); after reading this article, I believe you have some understanding of "sample Analysis of interrupt priority setting in SylixOS Lite version". If you want to know more about it, please follow the industry information channel and thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report