
Hardware semaphore (HSEM)
RM0453
366/1454
RM0453 Rev 2
The semaphore is free when its LOCK bit is 0. In this case, the COREID and PROCID are
also 0. When the LOCK bit is 1, the semaphore is locked and the COREID 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 COREID 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 COREID 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.
Figure 34. Procedure state diagram
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 COREID, and LOCK = 1. The COREID data
written by software must match the AHB bus master information. i.e. a AHB bus master
ID = 1writes data COREID = 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 COREID match the written data,
then the lock is confirmed.
•
Else retry (the semaphore has been locked by another process, AHB bus master ID).
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.
MS40534V3
WRITE (COREID & PROCID & LOCK =1)
or
READ LOCK
WRITE (COREID & PROCID & LOCK = 0)
WRITE (LOCK = 1)
or
WRITE (COREID or PROCID)
READ
or
READ LOCK
WRITE (LOCK = 0)
READ
Lock
Unlock
Locked
Free