HAL CORTEX How to Use

group CORTEX_How_To_Use

CORTEX main features

The HAL CORTEX driver contains four main blocks:

  1. NVIC: Nested Vector Interrupt Controller

    • The NVIC is an embedded interrupt controller that supports low-latency interrupt processing.

      • It contains a configurable interrupt handling ability. Configured items can be:

        • Priority grouping that specifies the range of preemption priority and sub priority.

        • Preemption priority ability between interrupts.

        • Subpriority ability between interrupts.

    • Within the Cortex-M33, the NVIC block is banked :

      • Secure NVIC to handle secure configurable interrupts.

      • Non-Secure NVIC to handle non-secure configurable interrupts.

  2. SYSTICK: System Timer

    • The SysTick, is a 24 bits count-down timer. It can be used as a simple counter or as tick timer in a real time operating system (RTOS).

    • Within the Cortex-M33, the SYSTICK block is banked :

      • Secure SYSTICK to be used for the secure application.

      • Non-Secure SYSTICK to be used for the non-secure application.

  3. MPU: Memory Protection Unit

    • The MPU allows a privileged software to define memory regions, assign memory access permission and memory attributes to each of them to improve the system reliability.

    • Within the Cortex-M33, the MPU block is banked :

      • Secure MPU to be used for secure regions definition (Up to 12 regions).

      • Non-Secure MPU to be used for non-secure regions definition (Up to 8 regions).

  4. SCB: System Control Block

    • The SCB provides system information and system control that includes configuration, control and reporting of system fault exceptions.

How to use the CORTEX HAL module driver

The CORTEX HAL driver can be used as follows :

This driver provides the HAL_CORTEX driver functions allowing to configure the NVIC, SYSTICK, MPU and SCB blocks.

  1. How to configure NVIC Interrupts using CORTEX HAL driver :

    • Configure the NVIC Priority Grouping using HAL_CORTEX_NVIC_SetPriorityGrouping() function ones at startup.

      • When the HAL_CORTEX_NVIC_PRIORITY_GROUP_0 is selected, IRQ pre-emption is no more configurable. The pending IRQ priority is managed only by the sub-priority.

      • When the HAL_CORTEX_NVIC_PRIORITY_GROUP_1 is selected, there is one bit for preemption priority and three bits for sub-priority.

      • When the HAL_CORTEX_NVIC_PRIORITY_GROUP_2 is selected, there are two bits for preemption priority and two bits for sub-priority.

      • When the HAL_CORTEX_NVIC_PRIORITY_GROUP_3 is selected, there are three bits for preemption priority and one bit for sub-priority.

      • When the HAL_CORTEX_NVIC_PRIORITY_GROUP_4 is selected, IRQ sub-priority is no more configurable. The pending IRQ priority is managed only by the pre-emption priority.

    • Configure the priority of the selected IRQ channels using HAL_CORTEX_NVIC_SetPriority() function :

      • IRQ priority order (sorted by highest to lowest priority):

        • The lowest is the preemption priority numerical value, the highest is the preemption priority.

        • The lowest is the subpriority numerical value, the the highest is the subpriority.

      • Get the priority grouping using HAL_CORTEX_NVIC_GetPriorityGrouping() function.

      • Get the priority of an interrupt using HAL_CORTEX_NVIC_GetPriority() function.

    • Enable the selected IRQ channels using HAL_CORTEX_NVIC_EnableIRQ() function.

    • Disable the selected IRQ channels using HAL_CORTEX_NVIC_DisableIRQ() function.

    • To check if an IRQ channel is enable or not, use HAL_CORTEX_NVIC_IsEnabledIRQ() function.

    • To check if an IRQ channel is active or not, use HAL_CORTEX_NVIC_IsActiveIRQ() function.

    • To set pending bit of an interrupt, use HAL_CORTEX_NVIC_SetPendingIRQ() function.

    • To check if the IRQn channel is in pending state or not, use HAL_CORTEX_NVIC_IsPendingIRQ() function. When pending, use HAL_CORTEX_NVIC_ClearPendingIRQ() to clear the event.

    • When a system reset is needed within the application, use HAL_CORTEX_NVIC_SystemReset() function.

    • Configure the security attribute of the selected interrupt using HAL_CORTEX_NVIC_SetIRQSecureAttr() function.

    • Get the security attribute of the Interrupt using HAL_CORTEX_NVIC_GetIRQSecureAttr() function.

    • Within the Cortex-M33 driver, all NVIC IRQ management functions are banked. APIs titled HAL_CORTEX_NVICNS_XXX() are provided to manage NVIC non-secure instance by a secure software.

  2. How to configure SYSTICK using CORTEX HAL driver :

  3. How to configure MPU using CORTEX HAL driver :

  4. How to configure SCB using CORTEX HAL driver :