Hardware semaphore (HSEM)
The semaphore is free when its LOCK bit is 0. In this case, the MASTERID and PROCID
are also 0. When the LOCK bit is 1, the semaphore is locked and the MASTERID indicates
which AHB bus master ID has locked it. The PROCID indicates which process of that AHB
bus master ID has locked the semaphore.
When write locking a semaphore, the written MASTERID must match the AHB bus master
ID , and the PROCID is written by the AHB bus master software process taking the lock.
When read locking the semaphore, the MASTERID is taken from the AHB bus master ID,
and the PROCID is forced to 0 by hardware. There is no PROCID available with read lock.
WRITE (LOCK = 0)
2-step (write) lock procedure
The 2-step lock procedure consists in a write to lock the semaphore, followed by a read to
check if the lock has been successful, carried out from the HSEM_Rx register
•
Write semaphore with PROCID and MASTERID, and LOCK = 1. The MASTERID data
written by software must match the AHB bus master information. i.e. a AHB bus master
ID = 1writes data MASTERID = 1.
Lock is put in place when the semaphore is free at write time.
•
Read-back the semaphore
The software checks the lock status, if PROCID and MASTERID match the written
data, then the lock is confirmed.
•
Else retry (the semaphore has been locked by another process).
A semaphore can only be locked when it is free.
A semaphore can be locked when the PROCID = 0.
Consecutive write attempts with LOCK = 1 to a locked semaphore are ignored.
298/1306
Figure 28. Procedure state diagram
WRITE (MASTERID & PROCID & LOCK = 1)
Free
READ
WRITE (MASTERID & PROCID & LOCK = 0)
or
READ LOCK
Lock
Unlock
RM0461 Rev 5
RM0461
WRITE (LOCK = 1)
or
WRITE (MASTERID or PROCID)
Locked
READ
or
READ LOCK
MSv41949V3
Need help?
Do you have a question about the STM32WLEx and is the answer not in the manual?