Skip to main content
gasda.1
Associate
May 17, 2020
Solved

HSEM HAL strange behavior

  • May 17, 2020
  • 4 replies
  • 1953 views

Hi,

I'm playing around HSEM module and i noticed strange behavior. Why calling:

HAL_HSEM_FastTake(HSEM_ID_0);

or

HAL_HSEM_Take(HSEM_ID_0, 0);

lock all semaphores at once instead of just locking single semaphore specified by a macro using 0 as processid?

Then calling release will unlock only the one specified macro and we end up with 31 semaphores locked unintentionally.

This topic has been closed for replies.
Best answer by TDK

Reading the RLR (read lock register), which you are doing by examining the value in peripheral mode, will lock the semaphore. Disable the RLR registers from being viewed.

4 replies

TDK
Super User
May 18, 2020

Why do you think it's locking all 32 semaphores?

"If you feel a post has answered your question, please click ""Accept as Solution""."
gasda.1
gasda.1Author
Associate
May 23, 2020

Because i've check it with debugger

This is state before calling HAL_HSEM_FastTake:

0693W000001pKq8QAE.png

and this is after:

0693W000001pKqDQAU.png

As you can see all semaphores has been locked by main cpu

TDK
TDKAnswer
Super User
May 23, 2020

Reading the RLR (read lock register), which you are doing by examining the value in peripheral mode, will lock the semaphore. Disable the RLR registers from being viewed.

"If you feel a post has answered your question, please click ""Accept as Solution""."
gasda.1
gasda.1Author
Associate
May 23, 2020

Oh you are defenitely right, viewing in peripheral mode does lock every semaphore. Thanks for clarification!