STM32CubeWBA: System modules

Revision as of 15:47, 27 March 2023 by Registered User

1. Introduction

This page regroups the wiki pages dedicated to STM32WBA systems modules. You can find information on concepts, how to use them, and on their APIs.

2. System modules

Below some system modules available on STM32WBA microcontrollers:

  • Memory management (dynamic allocation manager on a static pool, such as Allocation or Free)
  • Flash management (Interfaces and tools to execute flash operations, such as write or erase)
  • Real-time debugging (configuration and management of GPIOs for debug purposes)
  • System clock manager (management of clock frequency to select the best suitable frequency at the right time)
  • Low-power management (such as Interfaces for managing of power modes)
  • Trace management (low-impact trace manager API)

3. Background process

Some system modules are based on a request/callback mechanism: the user requests an operation to the module and she/he is notified later of the result. The operation is not executed at user call, but later.
This is made possible thanks to the "background process" method. The user call is used to check the feasibility of the operation, and the operation is executed by the background process function and, in a different context.

The typical workflow is the following:

  • The user request is analyzed and registered (it can be a request to check a parameter, a state, or a context). An error code about the result of the request is returned to the user.
  • The system module requests the scheduler for a future execution of its "Background Process" function. This function is in charge of the process of the concrete user operation.
  • The scheduler set active the system "Background Process" function. Once the operation is achieved, the system module notifies the user with his callback.

And it can be represented as follow:

Background process use case

3.1. User steps

Still, for this machinery to work, the user shall proceed to some steps.
Indeed, the "ProcessRequest" function is defined in the module but its implementation is missing and shall be achieved by the user. The content of this function will always be the same: Scheduling of the Background process function. However, you will have to adapt it to your operating system needs and specifies. Furthermore, do not forget to register the Background process function to your OS if needed for scheduling purposes.

Sum up
  • Register the Background function in the OS
  • Implement the Process request function to schedule the background function


Info white.png Information
An example of this setup is present in the How to section

3.2. How to

The following example explain how to setup the Background Process as a user. This can be applied to any module relying on a background process method.
This example deals with the advanced memory manager (AMM) module setup in a project relying on the sequencer.

Register the Background process function
The first thing before any use is to register the background process function of our system module:
/* Register the AMM background task */
UTIL_SEQ_RegTask( 1U << CFG_TASK_AMM_BCKGND, UTIL_SEQ_RFU, AMM_BackgroundProcess);
This way the background process function is registered for future scheduling.
Implement the Process request function
Once register of the background function is done, you shall implement the process request function. As said above, this function has to schedule the background function so the operation can be executed:
void AMM_ProcessRequest (void)
{
  /* Ask for AMM background task scheduling */
  UTIL_SEQ_SetTask(1U << CFG_TASK_AMM_BCKGND, CFG_SCH_PRIO_0);
}
Setup and initialize the module
After these two steps, you can now setup and initialize the memory manager module.
An example of AMM initialization can be found here.