This application note is written to guide designers through the steps required to build
specific Bluetooth
microcontrollers. It groups together the most important information and lists the aspects to
be addressed.
To fully benefit from the information in this document and to develop an application, the user
must be familiar with STM32 microcontrollers, BLE technology, 802.15.4 OpenThread
protocol, Zigbee
such as low power management and task sequencing.
®
Low Energy (BLE) or 802.15.4 applications based on STM32WB Series
®
protocol and 802.15.4 MAC layer, and has to understand system services
Figure 1. Protocols supported by STM32WB Series microcontrollers
AN5289 Rev 513/160
159
Software overviewAN5289
MS52413V1
CPU2
BLE radio
M0 firmware
CPU1
BLE Host stack
HostCtl interface
L2CAP
GATT, GAP
Application
ProfilesServices
SMPATT
HCL layer
BT MAC
Link layer
HostCtl interface
Figure 2. STM32WB Series microcontrollers BLE HCI layer model
3.2 BLE application
The STM32WB architecture separates the BLE profiles and application, running on the
application CPU1, from the real-time aspects residing in the BLE peripheral.
The BLE peripheral incorporates a CPU2 processor containing the stack handling the link
layer up to the GAP and the GAP layers. It also incorporates the physical 2.4 GHz radio.
The application CPU1 collects and computes the data to be transferred to the BLE.
CPU2 contains the LE controller and the LE host needed to manage all real time link layer
and radio PHY interaction which includes:
Low power manager to control Low-power mode
14/160AN5289 Rev 5
Debug trace to output information about activities
Mailbox / IPCC to interface the BLE stack (LL, GAP, GATT)
AN5289Software overview
CPU1
User code
MS51765V1
SRAM2IPCC
ACI - HCI
ProfilesServices
Application
CPU2
BLE stack
Radio PHY
GAPGATT
SMPATT
Link layerDTM
L2CAP
HCI
Figure 3. BLE application and wireless firmware architecture
3.3 Building a BLE application on top of the HCI layer interface
CPU2 may be used as a BLE HCI layer co-processor. In that case, the user either
implements its own HCI application or uses an existing open source BLE host stack.
Most BLE host stacks use a UART interface to communicate with a BLE HCI co-processor.
The equivalent physical layer on STM32WB Series microcontroller is the mailbox, as
described in
The mailbox provides an interface for both the BLE channel and the System channel. The
BLE host stack is responsible for building the command buffer to be sent over the BLE
channel on the mailbox and must provide an interface to report events received over the
mailbox. In addition to the BLE host stack adaptation over the mailbox, the user must notify
the mailbox driver when an asynchronous packet can be released.
The System channel is not handled by a BLE host stack. The user has to implement a
custom transport layer to build the system command buffer to be sent to the mailbox driver
and to manage the event received from the mailbox (including the notification to release an
asynchronous buffer to the mailbox driver), or it may use the mailbox extended driver (as
described in
Section 13.2: Mailbox interface.
Section 13.3: Mailbox interface - Extended) that provides an interface on top of
AN5289 Rev 515/160
159
Software overviewAN5289
the transport layer responsible for building the system command buffer and to manage the
system asynchronous event.
The BLE_TransparentMode project may be used as an example to build an application on
top of a BLE HCI layer co-processor using the mailbox as described in
Thread_Coap_DataTransfer.
Section 11.2:
3.4 Thread application
The OpenThread stack runs on CPU2 core and exports a set of APIs on CPU1 side in order
to build a complete Thread application. Three CPU2 firmwares support the Thread protocol:
sm32wb5x_Thread_FTD_fw: In this case, the device supports all Thread roles except
the border router (e.g. Leader, Router, End device, Sleepy end device).
stm32wb5x_Thread_MTD_fw: In this case, the device can act only as an end device
or sleepy end device). This configuration saves on memory space compared to the
FTD one.
stm32wb5x_BLE_Thread_fw: In this case, the device supports both Thread (FTD)
and BLE in static concurrent mode (refer to Section 3.6 for more details).
3.5 MAC 802_15_4 application
When downloading the STM32wb5x_Mac_802_15_4_fw CPU2 firmware, CPU1 can access
directly the 802_15_4 MAC layer and build its own application on top of it.
3.6 BLE and Thread application in concurrency
The STM32WB Series microcontrollers supports a “static concurrent mode” (also named
“switched mode”).
Both stacks (BLE and Thread) are embedded in the stm32wb5x_BLE_Thread_fw CPU2
firmware that is available from www.st.com. Switch from one protocol to the other is done
through a system application command. In this mode, the system disables the operational
protocol before activating the other one. The STM32WB device switches from BLE to
Thread after completely stopping the BLE stack, and vice versa. These transitions can take
several seconds, as the network needs to be reattached each time.
16/160AN5289 Rev 5
AN5289STM32WB software architecture
4 STM32WB software architecture
4.1 Main principles
All the code running on CPU2 is delivered as an encrypted binary
Black box for customer perspective
All the code running on CPU1 is delivered as source code
Communication between CPUs is done via “mailbox”
The standard STM32Cube delivery package includes STM32WB resources such as:
HAL/LL to access the hardware registers
BSP
Middleware (such as FreeRTOS, USB devices).
In addition, the following application provide efficient system integration:
A sequencer to execute the tasks in background and enter Low-power mode when
there is no activity
A timer server to provide virtual timers running on RTC (in Stop and Standby modes) to
the application.
AN5289 Rev 517/160
159
STM32WB software architectureAN5289
MS51862V2
Secure
Free but not available
in default linker file
Available in linker file
SRAM2A
_BASE
End of
User app
SRAM2A
_END_ADDR
SBRSA
SRAM2a
Secure
Free but not available
in default linker file
SRAM2B
_BASE
SRAM2B
_END_ADDR
SNBRSA
SRAM2b
Secure
Free but not available
in default linker file
Available in linker file
FLASH_BASE
End of
User app
FLASH
_END_ADDR
SFSA
Flash
Available in linker file
Not available in
default linker file
Reserved for BLE
OTA application
SRAM1_BASE
SRAM1
_END_ADDR
SRAM1
SRAM1_BASE
+ 4
4.2 Memory mapping
Figure 4. Memory mapping
The Flash, SRAM2a and SRAM2b memories contain a secure section, which cannot be
read nor written by CPU1. The secure start address for each memory can be read from the
option byte, indicated in blue in
SFSA for the Flash memory
SBRSA for the SRAM2a (retained in Standby)
SNBRSA for the SRAM2b.
Figure 4:
These option bytes are only written by the FUS running on CPU2. This is done on each
CPU2 update installed by the FUS.
The user application must take into account that the available memory may vary between
different versions of the RF stack. The available space for the user application can be
obtained from the release notes for STM32WB coprocessor wireless binaries. The install
address for the RF stack is also the boundary address for the user Flash memory area.
18/160AN5289 Rev 5
AN5289STM32WB software architecture
Ensure that some margin is included in CPU2 domain to support updates during the product
lifetime.
The boundary granularity is 4 Kbytes for the Flash memory and 1 Kbyte for both SRAM2a
and SRAM2b.
The linker file is identical to all delivered BLE/Thread applications (except for
BLE_Thread_Static, BLE_HeartRate_ota and BLE_p2pServer_ota). The available
memories are chosen to fit all provided applications. For applications like BLE, where CPU2
memory requirements are smaller, it is possible to update the linker file to allocate more
memory to the application.
To optimize the available memory for a dedicated application, the linker file has to be
updated inline with the following guidelines:
Flash memory: the end of available memory address can be moved up to the SFSA
address. When a CPU2 update is required, there must be enough free memory just
below the secure memory to upload a new encrypted CPU2 FW update. The size of the
memory required depends on CPU2 FW to be updated (BLE, Thread or concurrent
BLE/Thread), see [1].
SRAM1: the first unavailable 32 bits in the linker file are only required for the BLE_OTA
application. For all other applications, the start address can be moved from
SRAM1_BASE + 4 to SRAM1_BASE.
SRAM2a: the end of available memory address can be moved up to the SBRSA
address. When CPU2 update support required, there must be some free sectors just
below the secure memory to support new CPU2 FW updates requiring more sectors to
be secure.
SRAM2b: The SRAM2b is not part of the linker file because it is all secure for any FW
CPU2 supporting the Thread protocol. For BLE only applications, the linker file may be
updated with a new section to map RW data into the SRAM2B from SRAM2B_BASE
up to the SNBRSA address. When CPU2 update support required, there must be some
free sectors just below the secure memory to support new CPU2 FW updates requiring
more sectors to be secure.
STOP2 is the deepest low power mode supported when RF is active. When the user
application has to enter Standby mode, it must first stop all RF activities, and fully
re-initialize CPU2 when coming out of Standby mode. The user application may use the full
non secure SRAM2a to store its own content (that needs to be retained in Standby mode).
4.3 Shared peripherals
All peripherals concurrently accessible by both CPUs are protected by hardware
semaphores. Before accessing these peripherals, the associated semaphore must first be
taken, and released afterwards.
SemaphorePurpose
Sem0RNG - All registers
Sem1PKA - All registers
Sem2FLASH - All registers
Table 2. Semaphores
AN5289 Rev 519/160
159
STM32WB software architectureAN5289
Table 2. Semaphores (continued)
SemaphorePurpose
RCC_CR
Sem3
Sem4Clock control mechanism for the Stop mode implementation.
Sem5
Sem6Used by CPU1 to prevent CPU2 from writing/erasing data in Flash memory.
Sem7Used by CPU2 to prevent CPU1 from writing/erasing data in Flash memory.
RCC_EXTCFGR
RCC_CFGR
RCC_SMPSCR
RCC_CRRCR
RCC_CCIPR
Sem8
Sem9
Ensures that CPU2 does not update the Thread persistent data in SRAM2 when
CPU1 is reading them.
Ensures that CPU2 does not update the BLE persistent data in SRAM2 when
CPU1 is reading them.
If the application needs to use semaphores for inter task control, it is recommended to start
using Sem31 downwards to be compatible with future wireless firmware updates on CPU1,
where new features may be added requiring additional semaphores.
Sem0 is used to share the RNG IP between the two CPUs. The semaphore is taken by the
CPU2 for a time interval depending upon the required RNG number to be generated and
upon the RNG source clock speed. To relax the latency to get RNG numbers, it is
recommended to generate at startup a pool of RNG numbers and fill the pool in a low
priority task when some numbers are retrieved by the application to keep it full. The usage
of Sem0 is shown in
Figure 8.
Sem 0 can be used in the USB use case too. When the USB is not used anymore and
needs to be switched off by the application, Sem 0 must be taken before switching off the
CLK48 clock. This is required because USB and RNG share the same clock, and CPU2
could use RNG at the same time when CPU1 needs to switch off the USB (see
Figure 9).
Sem1 is used to share the PKA IP between the two CPUs.
Sem2 is used to share the FLASH IP between the two CPUs. The semaphore is taken by
the CPU2 for a time interval depending upon the number of data to be written in the Flash
memory and upon the number of sectors to erase. BLE stack writes to Flash memory the
pairing information (when bonding is enabled) and the GATT attribute cache.
Sem3 is used for the low power management. It must not be locked for more than 500 µs by
the CPU1 when there is BLE RF activity. The algorithm is detailed in
Sem4 is used to handle race condition on the switch of the system clock when a CPU exits
low power mode while the other one enter low power mode. The algorithm is detailed in
Figure 6 and Figure 7.
Sem3 and Sem4 are used in the examples to enter/exit Stop mode.
The user must ensure that the algorithms shown in Figure 6 and Figure 7 are executed
before and after wake-up from Stop mode. These routines (see Figure 5) are usually
implemented inside the IDLE task of sequencer or RTOS. The implementation takes
advantage of the fact that when WFI is called from critical section, the MCU wakes up upon
20/160AN5289 Rev 5
Figure 6 and Figure 7.
AN5289STM32WB software architecture
MS53131V1
Thread
PWR_Enter
StopMode()
zzz
PWR_Exit
StopMode()
ISRThread
IRQx
Enter
critical section
Exit
critical section
WFI
Interrupt
exit
interrupt request, but instead of executing ISR it continues to execute the next instruction
after WFI. Only after exiting the critical section the ISR is executed.
PRIMASK = 0; // Unmask all interrupts (exit critical section)
Figure 5. Timing for entering/exiting Stop mode on CPU1
AN5289 Rev 521/160
159
STM32WB software architectureAN5289
MS53122V1
Yes
No
Enter
ENTER_CRITICAL_SECTION
EXIT_CRITICAL_SECTION
Exit
Poll Sem3 until granted
Get Sem4
Sem4 granted ?
C2DS = set ?
Release Sem4
Release Sem3
Set HSION
Wait for HSIRDY
Set SW to HSI
Wait for SWS to report HSI
Set SMPSSEL to HSI
Yes
No
If Sem4 is busy CPU2 has not switched
the clock to HSI.
It is either in Stop mode, or polling Sem3
to exit Stop mode (in this case, the clock
is switched to HSI and switched back to
another clock by the CPU2)
CPU2 is either in Run mode on a suitable
clock, or polling Sem3 to exit Stop mode
CPU2 is either in Stop mode, or polling
Sem3 to exit Stop mode (in this case, the
clock is switched to HSI and switched
back to another clock by the CPU2)
Enter CStop
Figure 6. Algorithm to enter Stop mode on CPU1
22/160AN5289 Rev 5
AN5289STM32WB software architecture
MS53123V1
Enter
ENTER_CRITICAL_SECTION
EXIT_CRITICAL_SECTION
Exit
Poll Sem3 until granted
SWS = HSI ?
Release Sem3
Clock configuration
CPU1 must configure all clocks,
depending on the use case (it
must commit CPU2 at 32 MHz)
Yes
No
Only if HSE is suitable for CPU1 use case.
Release Sem4
Polling time is short, can be kept in the
critical section.
Figure 7. Algorithm to exit Stop mode on CPU1
Sem5 is used to control the RNG/USB CLK48 source clock. The CPU2 updates or switches
off the clock only when the RNG IP (Sem0) is used.
To avoid a race condition with the CPU2, when the CPU1 needs to switch off the clock it
must always first get Sem0, even if not using the RNG IP. This mechanism is shown in the
BLE P-NUCLEO-WB55.USB dongle examples (see
Figure 9). This does not impact the CPU2.
Section 7.1.3: Configuration and
AN5289 Rev 523/160
159
STM32WB software architectureAN5289
MS53124V1
RNG entry
Configure and switch on RNG clock
Exit
RNG process
Release Sem0
Poll Sem0 until granted
Switch off RNG IP
Switch off RNG clock
Set RNGSEL = CLK48
Figure 8. Algorithm to use RNG on CPU1
Note:Sem5 is not taken because the CPU2 does not take it without taking first Sem0. This
algorithm can be updated to take Sem5 before configuring the RNG clock source.
24/160AN5289 Rev 5
AN5289STM32WB software architecture
MS53125V1
USB entry
Configure and switch on CLK48
Exit
Switch on USB IP
Switch off CLK48
Poll Sem5 until granted
USB process
Switch off USB IP
Get Sem0
Sem0 granted ?
Release Sem0
Release Sem5
Enable Sem0 IT and
wait for free interrupt
No
Yes
Figure 9. Algorithm to use USB on CPU1
The USB and RNG IPs share the same source clock. Before switching off the clock, the
USB driver must first check whether the CPU2 requires the clock or not. To avoid a race
condition with the CPU2, the CPU1 must first get Sem0 (RNG semaphore, CPU2 does not
use USB) before switching off the clock.
If Sem0 is busy, the CPU1 must wait for Sem0 to be free to switch off the clock. This is
required because there can be a race condition when CPU1 releases the USB and CPU2
releases the RNG at the same time, leading to the oscillator to be kept on.
Sem6 is used to protect the CPU1 timing versus write/erase operations requested by the
CPU2. The CPU1 shall get Sem6 to prevent the CPU2 or other CPU1 processes to either
write or erase data in Flash memory. There is no time limit on how long the CPU1 can keep
the semaphore, but, as long as the semaphore is taken, the CPU2 is unable to write either
the pairing or client descriptor information in the memory.
CPU1 has to release Sem6 only if it can afford being stalled for the time required to finish
the write or erase operation.
The CPU2 implements the algorithm described in Figure 10, similarly to the CPU1. Before
writing or erasing data in Flash memory, it tries to get Sem6 and, if successful, writes/erases
AN5289 Rev 525/160
159
STM32WB software architectureAN5289
data and releases the semaphore. When the CPU1 needs to protect its timing, it polls Sem6
until it gets it.
Sem7 is used to protect the CPU2 timing versus write/erase Flash memory operation
requested by CPU1. The CPU1 must get Sem7 before writing or erasing. Sem7 must be
taken and released for each single write or erase operation, but for not more than 0.5 ms in
addition to the write/erase timing. To comply with this requirement the code must be
executed in the critical section. The algorithm is described in
AES2 is reserved to the CPU2 and must never be used/accessed by the CPU1.
AES1 is reserved to the CPU1 and is never used/accessed by the CPU2. The only case
when the CPU2 accesses the AES1 is when the CPU1 requests to write a user key on the
customer key storage area. This is described in
Sem8 is used to ensure that CPU2 does not update the BLE persistent data in SRAM2
while CPU1 reads them.
The CPU2 may be configured to store the BLE persistent data either in the internal NVM
storage on CPU2 or in the SRAM2 buffer provided by the user application. This can be
configured with the system command SHCI_C2_Config() when the CPU2 is requested to
store persistent data in SRAM2, so it can write data in this buffer when needed. To read
consistent data with the CPU1 from the SRAM2 buffer, the flow must be:
1.CPU1 takes Sem8
2. CPU1 reads all persistent data from SRAM2 (most of the time, the goal is to write these
data into an NVM managed by CPU1)
3. CPU1 releases Sem8
[6].
Figure 10.
There is no timing constraint on how long this semaphore can be kept.
Sem9 is used to ensure that CPU2 does not update the Thread persistent data in SRAM2
while CPU1 reads them.
The CPU2 may be configured to store the Thread persistent data either in the internal NVM
storage on CPU2 or in the SRAM2 buffer provided by the user application. This can be
configured with the system command SHCI_C2_Config() when the CPU2 is requested to
store persistent data in SRAM2, so it can write data in this buffer when needed. To read
consistent data with the CPU1 from the SRAM2 buffer, the flow must be:
1.CPU1 takes Sem9
2. CPU1 reads all persistent data from SRAM2 (most of the time, the goal is to write these
data into an NVM managed by CPU1)
3. CPU1 releases Sem9
There is no timing constraint on how long this semaphore can be kept.
4.4 Sequencer
The sequencer executes registered functions one by one. It has the following features:
supports up to 32 functions
requests functions to be executed
enables / disables the execution of a function
provides a blocking interface based on the reception of an event.
26/160AN5289 Rev 5
AN5289STM32WB software architecture
The sequencer provides a simple background scheduling function. It provides a hook to
implement a secure way Low-power mode (no event loss) when the sequencer does not
have any pending tasks to be executed. It also provides an efficient mechanism for the
application to wait for a specific event before moving forward. When the sequencer is
waiting for a specific event, it provides a hook where the application may either enter
Low-power mode or execute some other code.
4.4.1 Implementation
To use the sequencer, the application must:
set the number of maximum of supported functions (this is done by defining a value for
UTIL_SEQ_CONF_TASK_NBR)
register a function to be supported by the sequencer with UTIL_SEQ_RegTask()
start the sequencer by calling UTIL_SEQ_Run() to run a background while loop
call UTIL_SEQ_SetTask() when a function needs to be executed.
4.4.2 Interface
FunctionDescription
void UTIL_SEQ_Idle( void );Called (in critical section - PRIMASK) when there is nothing to execute.
Requests the sequencer to execute functions that are pending and
enabled in the mask mask_bm.
Registers a function (task) associated with a signal (task_id_bm) in the
sequencer. The task_id_bm must have a single bit set.
Requests the function associated with the task_id_bm to be executed.
The task_prio is evaluated by the sequencer only when a function has
finished. If several functions are pending at any one time, the one with the
highest priority (0) is executed.
Disables the sequencer to execute the function associated with
task_id_bm.
Enables the sequencer to execute the function associated with
task_id_bm.
Requests the sequencer to wait for a specific event evt_id_bm and does
not return until the event is set with UTIL_SEQ_SetEvt().
Notifies the sequencer that the event evt_id_bm occurred (the event must
have been first requested).
Called while the sequencer is waiting for a specific event.
void UTIL_SEQ_ClrEvt(
UTIL_SEQ_bm_t evt_id_bm )
UTIL_SEQ_bm_t
UTIL_SEQ_IsEvtPend( void )
Clears the pending event.
Returns the evt_id_bm of the pending event.
AN5289 Rev 527/160
159
STM32WB software architectureAN5289
4.4.3 Detailed interface and behavior
The sequencer is a packaging of while loops to call functions when requested by the user:
while(1)
{
if(task_id1)
{
task_id1 = 0;
Fct1();
}
if (task_id2)
{
task_id2= 0;
Fct2();
}
__disable_irq();
If (! (task_id1|| task_id2))
{
UTIL_SEQ_Idle();
}
__enable_irq();
}
void UTIL_SEQ_Run(UTIL_SEQ_bm_t mask_bm)
Implements the body of the while (1) loop. The mask_bm parameter is the list of functions
that the sequencer is allowed to execute. Each function is associated with one bit in that
mask_bm. At the end of the startup, this API must be called in a while (1) loop with
mask_bm = (~0) to allow the sequencer to execute any pending function.
void UTIL_SEQ_Idle( void )
Called under the critical section (set with the CortexM PRIMASK bit - all interrupts are
masked) when the sequencer does not have any function to executed. This is where the
application must enter the Low-power mode.
Sets the flag task_id_bm for the scheduler to call the associated function.
28/160AN5289 Rev 5
AN5289STM32WB software architecture
The task_prio is evaluated by the sequencer when it needs to decide which function to call
next. This can be done only when the execution of the current function is finished. When
several functions have their flag set, the one with the higher priority is executed (0 is the
highest). This API may be called several times before the function is actually executed with
a different priority. In that case, the sequencer records the highest priority. Whatever the
number of API calls before the function is executed, the sequencer runs the associated
function only once.
Informs the sequencer not to execute the function associated with the flag task_id_bm even
if it is set. If the API UTIL_SEQ_SetTask() is called after UTIL_SEQ_PauseTask(), the
request is recorded but the function is not executed. The mask associated with
UTIL_SEQ_PauseTask() is independent from the mask associated with
void UTIL_SEQ_Run(UTIL_SEQ_bm_t mask_bm).
A function can be executed only when its flag is set and enabled in both masks (default
case).
Cancels the request done by UTIL_SEQ_PauseTask(). If this API is called when no
UTIL_SEQ_PauseTask() has been requested, it has no effect.
void UTIL_SEQ_WaitEvt( UTIL_SEQ_bm_t evt_id_bm )
When this API is called, it does not return until the associated evt_id_bm signal is set. Only
one bit in the evt_id_bm 32-bit value needs to be set. While the sequencer is waiting for this
event, it calls UTIL_SEQ_EvtIdle() in a while loop on the event evt_id_bm. This has to be
used to replace all code where a polling is made on a flag before moving forward.
void UTIL_SEQ_SetEvt( UTIL_SEQ_bm_t evt_id_bm )
Must be called only when UTIL_SEQ_WaitEvt() has already been called. It sets the signal
evt_id_bm the function UTIL_SEQ_WaitEvt() is waiting for. Calling this API before the
UTIL_SEQ_WaitEvt() function makes the call to UTIL_SEQ_WaitEvt() return immediately as
the flag is already set.
Called while the API void UTIL_SEQ_WaitEvt() is waiting for the signal to be set with
UTIL_SEQ_SetEvt().
This API is weakly implemented in the sequencer to call UTIL_SEQ_Run(0), which means
that while waiting for this event to occur, the function UTIL_SEQ_Idle() allows the system to
enter Low-power mode while waiting for the flag.
The application may implement this API to pass parameters that are different from 0 to the
UTIL_SEQ_Run(mask_bm). Each bit set to 1 in the mask_bm requests the sequencer to
execute the function associated with this flag when it is set with UTIL_SEQ_SetTask(). This
means that when the function UTIL_SEQ_WaitEvt() is called, while it is waiting for the
requested event to return, it may either execute the unmasked functions when their flag is
set, or call UTIL_SEQ_Idle() if no tasks is pending execution by the sequencer.
AN5289 Rev 529/160
159
STM32WB software architectureAN5289
void UTIL_SEQ_ClrEvt( UTIL_SEQ_bm_t evt_id_bm )
This API may be called when, in some applications, the API UTIL_SEQ_WaitEvt() needs to
be called while Evt is already set. In that case, the Evt must be cleared.
UTIL_SEQ_bm_t UTIL_SEQ_IsEvtPend( void ):
This API returns the Evt that is currently pending. When several UTIL_SEQ_WaitEvt() are
nested, it returns the last one, which means the one that makes the deeper
UTIL_SEQ_WaitEvt() to return to its caller.
4.5 Timer server
The timer server has the following features:
Up to 255 virtual timers depending on available RAM capacity
Single shot and repeated mode
Stops a virtual timer and restarts it with a different timeout value
Deletes a timer
Timeout from 1 to 2
The timer server provides multiple virtual timers sharing the RTC wakeup timer. Each virtual
timer may be defined as either single shot or a repeated timer. When a repeated timer
comes to the end of a cycle, the user is notified and the virtual timer is automatically
restarted with the same timeout. When a single shot timer ends, the user is notified and the
virtual timer is set to the pending state (which means it is kept registered and may be
restarted at any time). The user may stop a virtual timer and restart it with a different timeout
value. When a virtual timer is no longer needed, the user must delete it to free the slot in the
timer server.
32
- 1 ticks
The timer server can be used concurrently with the calendar.
4.5.1 Implementation
To use the timer server, the application must:
Configure the RTC IP. When the calendar is required in the application, the RTC
configuration must be compatible with the calendar settings requirement. When the
calendar is not used, the RTC may be optimized for a Timer Server usage only.
Initialize the timer server with HW_TS_Init().
Implement HW_TS_RTC_Int_AppNot() (optional). When not implemented, the timer
callback is called in the RTC interrupt handler context.
Create a virtual timer with HW_TS_Create().
Use the virtual timer with HW_TS_Stop(), HW_TS_Start().
Delete the virtual when not needed using HW_TS_Delete().
30/160AN5289 Rev 5
Loading...
+ 130 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.