Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of interrupt priority setting in SylixOS Lite version

Shulou Source: shulou.com Published: 2022-06-02 12:17:14 10月03日 Update

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!

Tags: Priority version mode list program peripheral interface function register example analysis code article chip assembly language location architecture role key Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Information MySQL Microsoft MariaDB