2020-05-17 09:37 AM
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.
Solved! Go to Solution.
2020-05-23 07:37 AM
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.
2020-05-17 06:47 PM
Why do you think it's locking all 32 semaphores?
2020-05-23 03:56 AM
Because i've check it with debugger
This is state before calling HAL_HSEM_FastTake:
and this is after:
As you can see all semaphores has been locked by main cpu
2020-05-23 07:37 AM
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.
2020-05-23 08:23 AM
Oh you are defenitely right, viewing in peripheral mode does lock every semaphore. Thanks for clarification!