STMicroelectronics STM32WLEx Reference Manual page 299

Advanced arm-based 32-bit mcus with sub-ghz radio solution
Table of Contents

Advertisement

RM0461
1-step (read) lock procedure
The 1-step procedure consists in a read to lock and check the semaphore in a single step,
carried out from the HSEM_RLRx register.
Read lock semaphore with the AHB bus master MASTERID.
If read MASTERID matches and PROCID = 0, then lock is put in place. If MASTERID
matches and PROCID is not 0, this means that another process from the same
MASTERID has locked the semaphore with a 2-step (write) procedure.
Else retry (the semaphore has been locked by another process).
A semaphore can only be locked when it is free. When read locking a free semaphore,
PROCID is 0. Read locking a locked semaphore returns the MASTERID and PROCID that
locked it. All read locks, including the first one that locks the semaphore, return the
MASTERID that locks or locked the semaphore.
Note:
The 1-step procedure must not be used when running multiple processes of the same AHB
bus master ID. All processes using the same semaphore read the same status. When only
one process locks the semaphore, each process of that AHB bus master ID reads the
semaphore as locked by itself with the MASTERID.
7.3.4
HSEM write/read/read lock register address
For each semaphore, two AHB register addresses are provided, separated in two banks of
32-bit semaphore registers, spaced by a 0x80 address offset.
In the first register address bank the semaphore can be written (locked/unlocked) and read
through the HSEM_Rx registers.
In the second register address bank the semaphore can be read (locked) through the
HSEM_RLRx registers.
7.3.5
HSEM unlock procedures
Unlocking a semaphore is a protected process, to prevent accidental clearing by a AHB bus
master ID or by a process not having the semaphore lock right. The procedure consists in
writing to the semaphore HSEM_Rx register with the corresponding MASTERID and
PROCID and LOCK = 0. When unlocked the semaphore, the MASTERID, and the PROCID
are all 0.
When unlocked, an interrupt may be generated to signal the event. To this end, the
semaphore interrupt must be enabled.
The unlock procedure consists in a write to the semaphore HSEM_Rx register with
matching MASTERID regardless on how the semaphore has been locked (1- or 2-step).
Write semaphore with PROCID, MASTERID, and LOCK = 0
If the written data matches the semaphore PROCID and MASTERID and the AHB bus
master ID , the semaphore is unlocked and an interrupt may be generated when
enabled, else write is ignored, semaphore remains locked and no interrupt is generated
(the semaphore is locked by another process or the written data does not match the
AHB bus master signaling).
Note:
Different processes of the AHB bus master ID can write any PROCID value. Preventing
other processes of the AHB bus master ID from unlocking a semaphore must be ensured
by software, handling the PROCID correctly.
RM0461 Rev 5
Hardware semaphore (HSEM)
299/1306
308

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the STM32WLEx and is the answer not in the manual?

Table of Contents