cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H745: Freeing a semaphore does not trigger an interrupt

Hansel
Senior

There is very little information on the internet, let alone any example that I could look at. My problem is that freeing a semaphore does not trigger an interrupt. I need this feature to allow one core to notify the other in case a certain condition arises in software during runtime.

The code is simple:

#define TR_EVENT 16
 
// Clear all interrupts
HSEM->C1ICR  = 0xFFFFFFFF;
// Reset interrupt status register
HSEM->C1ISR  = 0;
// Reset interrupt mask register
HSEM->C1MISR = 0;
// Turn on interrupt for TR_EVENT
HSEM->C1IER |= (1 << TR_EVENT);
 
 // Lock semaphore TR_EVENT
SEM_SET(TR_EVENT);
// Unlock semaphore TR_EVENT
// ---> should trigger the interrupt:
SEM_RESET(TR_EVENT, SEM_CM4);

Before entering line 16, the content of the HSEM registers look as follows:

0693W00000NrgNjQAJ.png 

After line 16, the content is this:

0693W00000NrgNoQAJ.png 

So it appears the resetting of the corresponding semaphore properly sets the interrupt registers, but an actual interrupt does not occur. Anyone have some experience with semaphore interrupts? Who could steer me in the right direction to find out what's missing?

For completeness sake, here are the macros I am using for setting and resetting the semaphores:

#define SEM_CM7     (3 << 8) // Table 94 in RM0399
#define SEM_CM4     (1 << 8)
#define SEM_PROC_ID (0 << 0)
 
#define SEM_SET(semID) \ 
((void) HSEM->RLR[(semID)])
#define SEM_RESET(semID, coreID) \
(HSEM->R[(semID)] = (coreID) | (SEM_PROC_ID))

The interrupt routine is registered in the startup code. My implementation of it looks like this:

void HSEM1_IRQHandler(void) {
	P_HSEM->C1ISR &= ~(1 << TR_EVENT);
}

1 ACCEPTED SOLUTION

Accepted Solutions
Hansel
Senior

Just minutes after posting, I found the problem. I forgot to enable the interrupt. D'oh!

NVIC_SetPriority(HSEM1_IRQn, 6);
NVIC_EnableIRQ(HSEM1_IRQn);

View solution in original post

1 REPLY 1
Hansel
Senior

Just minutes after posting, I found the problem. I forgot to enable the interrupt. D'oh!

NVIC_SetPriority(HSEM1_IRQn, 6);
NVIC_EnableIRQ(HSEM1_IRQn);