STM32 xSemaphoreGive Interrupt infinite Loop

Hi, Currently I am using STM32 Cortex M3, compiler IAR 4.x & FreeRTOS v6.1.0. I have 2 interrupt task for the moment, interrupt from CAN bus & periodic software interrupt.
void vPeriodicTask( void *pvParameters )
{
       
  portTickType xLastExecutionTime;
  xLastExecutionTime = xTaskGetTickCount();
  
  for(;;)
  {
    xSemaphoreGive(SEM_INT);
    vTaskDelayUntil( &xLastExecutionTime, 10000/portTICK_RATE_MS);
  }
}
void USB_LP_CAN_RX0_IRQHandler(void)
{
   
   CAN_Receive(CAN_FIFO0, &RxMessage);
  
   portBASE_TYPE xHighxHigherPriorityTaskWoken = pdFALSE;
   xSemaphoreGiveFromISR( SEM_CAN_INT, &xHighxHigherPriorityTaskWoken);
   portEND_SWITCHING_ISR(xHighxHigherPriorityTaskWoken);
           
}
Then if I put a break point at xSemaphoreGive(SEM_INT); under periodic task. I found that it looks like execute this line for so many times before xSemaphoreTake( SEM_INT, portMAX_DELAY); been unblocked. The way I test it press F5 when process stop at break point, my expectation is it will execute next line when I press F5. Am I make wrong assumption? On the other hand, my program freeze at this line for
( pxIterator = ( xListItem * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) 
after 1-2 hour running. Turned on stack overflow check but catch nothing. Non-of the interrupt firing before startscheduler execute. Could you please advise this? Thank you so much for your support.

STM32 xSemaphoreGive Interrupt infinite Loop

Have you taken account of point 3 on the following page?  Your symptoms would suggest not. www.freertos.org/FAQHelp.html Regards.

STM32 xSemaphoreGive Interrupt infinite Loop

Hi Richard, I saw point 3 before , but I don’t think I have using any API in ISR. My interrupt handler task as below, please advise.
void USB_LP_CAN_RX0_IRQHandler(void)
{
   
   CAN_Receive(CAN_FIFO0, &RxMessage);
  
   portBASE_TYPE xHighxHigherPriorityTaskWoken = pdFALSE;
   xSemaphoreGiveFromISR( SEM_CAN_INT, &xHighxHigherPriorityTaskWoken);
   portEND_SWITCHING_ISR(xHighxHigherPriorityTaskWoken);
           
}
But I doubt if I really understand well on interrupt priority parts, below are the code I use to enable CAN interrupt.
        
NVIC_InitStructure.NVIC_IRQChannel=USB_LP_CAN_RX0_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
My FreeRTOSConfig.h setting as default.
/* This is the raw value as per the Cortex-M3 NVIC.  Values can be 255
(lowest) to 0 (1?) (highest). */
#define configKERNEL_INTERRUPT_PRIORITY     255
#define configMAX_SYSCALL_INTERRUPT_PRIORITY    191 /* equivalent to 0xb0, or priority 11. */
/* This is the value being used as per the ST library which permits 16
priority values, 0 to 15.  This must correspond to the
configKERNEL_INTERRUPT_PRIORITY setting.  Here 15 corresponds to the lowest
NVIC value of 255. */
#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15
The priority mentioned in point 3 refered to NVIC_IRQChannelPreemptionPriority or create task priority? Which is priority 3 for my task. Please advise. Thank you so much for your reply.

STM32 xSemaphoreGive Interrupt infinite Loop

I saw point 3 before , but I don’t think I have using any API in ISR.
You are calling xSemaphoreGiveFromISR() from the ISR, so you are using a FreeRTOS API function in the ISR.  Therefore you *must* set your interrupt priorities correctly otherwise you will get the exact symptom you are describing.
NVIC_InitStructure.NVIC_IRQChannel=USB_LP_CAN_RX0_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
You are setting the interrupt to the highest possible priority, this is exactly what the linked warning is telling you not to do, and will result in the behaviour you are describing. There are lots of other posts on this subject.  Please learn about the MCU before learning about FreeRTOS. Regards.

STM32 xSemaphoreGive Interrupt infinite Loop

Hi Richard, Thanks for your reply. Understand that almost 95% support request on this issue. I go through both purchased FreeRTOS both ebooks but still not fully understand on interrupt nesting priority configuration with FreeRTOS implemented.
#define configKERNEL_INTERRUPT_PRIORITY     255
#define configMAX_SYSCALL_INTERRUPT_PRIORITY    191 /* equivalent to 0xb0, or priority 11. */
Understand that KERNEL_INTTERRUPT_PRIORITY advice to remain at lowest which is 255. But MAX_SYSCALL_INTERRUPT_PRIORITY why set to priority 11? Is this value set for demo or we can change it accordingly to our requirement? So far I am not facing problem without using RTOS, so I am lack of knowledge in interrupt priority configuration. So I wish that you could guide me on this issue. From the purchased ebooks, it mentioned that priority of ISR that using FreeRTOS API should between MAX_SYSCALL_PRIORITY & KERNEL_INT_PRIORITY. Is this limit to API that end with “FromISR” or all RTOS API? If I set my MAX_SYSCALL_PRIORITY to 0, then KERNEL_PRIORITY as default 255. Is that mean my NVIC priority of ISR that using FreeRTOS API can use any priority between 0-255? But changing MAX_SYSCALL_PRIORITY to highest will causing any problem? Please advise me on this. Thanks in advanced. Regards.

STM32 xSemaphoreGive Interrupt infinite Loop

Hi.
I have similar problem with you.
Did you find out the solution ?
If so, could you please let me know ?

STM32 xSemaphoreGive Interrupt infinite Loop

irvind,
The only problem that I know that setting MAX_SYSCALL_PRIORITY to 0 will cause is that it then becomes impossible to have an interrupt (that doesn’t call FreeRTOS) , at a priority above MAX_SYSCALL_PRIORITY so that it doesn’t get delayed by critical sections in the kernel and user code. (Non-maskable interrupts/traps still can not call the FreeRTOS API) quartus,
If you have the same problem, then you probably have the same solution. Any interrupt function that calls FreeRTOS functions must use the FromISR versions, and must have a priority lower (which on some processors is a smaller number and other is a larger number).