We make new project with PIC32MX370F512L. FreeRTOS port is 9.0.0. We have interrupt issues. I attach sample project which demonstrates the problem:
There is interrupt handler for TIMER2, also interrupt setting to the timer. When xSemaphoreCreateMutex() function is called, the interrupt does not work. It doesn’t matter if the scheduler is started or not. I checked already - timer2 is not used by the scheduler for any purpose. The priority level of the timer match the priority level of the handler. The interrupts are enabled.
When i comment the function xSemaphoreCreateMutex(), the interrupts are working. The attached project includes the FreeRTOS config, configuration bits and all needed features for test even on simulator
In your main() function - the call to xSemaphoreCreateMutex() - or ANY FreeRTOS API function - will deliberately leave interrupts disabled. When the scheduler starts, interrupts will automatically be enabled again.
This is done to prevent interrupts attempting to use an RTOS service or perform a context switch before the scheduler has been started.
Hi, Thanks for the information, there are two points:
If you check the main(function) - in the test case when the scheduler is not used - There is INTEnableSystemMultiVectoredInt() call /After the API usage/, which enables the interrupts manually even if they are disabled by the xSemaphoreCreateMutex() API call.
Second point is, that if i allow the scheduler to start (even with no created tasks the Idle task will be executed all time), the interrupts does not start and the idle task just runs all time without interruption
My be you mean, that the xSemaphoreCreateMutex() disables the interrupts in such a way, that only vTaskStartScheduler() can enable them and the standard peripheral library for the interrupts will not work until the scheduler is started? In this case i need to double check what happens in this case and will return feedback?
Thank you for your time, if you need anything from our side, just let me know.
Kind regards
Dimitar
If you check the main(function) - in the test case when the scheduler is
not used - There is INTEnableSystemMultiVectoredInt() call /After the
API usage/, which enables the interrupts manually even if they are
disabled by the xSemaphoreCreateMutex() API call.
Hmm. The FreeRTOS code masks priority bits in the _CP0_STATUS register.
I think INTEnableSystemMultiVectoredInt() operates on a different
register, maybe using a global enable/disable bit, so calling
INTEnableSystemMultiVectoredInt() will not unmask the interrupts that
were masked by FreeRTOS. Try calling portENABLE_INTERRUPTS() instead.
Hi, I made the test, the interrupts are now working, thanks for the suggestion. The next problem is, that when i start the scheduler, the MCU resets after 1-2sec after the scheduler is started. If i dnot’t start the scheduler, the MCU stays stable. The problem is even when no task is created, no api functions are called prior the vTaskStartScheduler(). As far as my debug tool says is: “Target halted due to Software Breakpoint in user code”. I provide test code: Empty main function, no interrupts enabled, no tasks creatated. In debug mode i place breakpoint inside the idle task tick hook and it breaks many time, but when i run the target, it resets.
Due to this project is migration from PIC24E part, if we manage to stabilize the interrupts and general behavior here, we can port our application level without issues, thanks in advance: The FreeRTOS config and configuration bits remai unchanged.
void main(void)
{
// Enable the pre-fetch cache module to achieve 100MHz Tcy:
CHECON = 0b00000000000000000000001100110010;
Hi, I made the test, the interrupts are now working, thanks for the suggestion. The next problem is, that when i start the scheduler, the MCU resets after 1-2sec after the scheduler is started. If i dnot’t start the scheduler, the MCU stays stable. The problem is even when no task is created, no api functions are called prior the vTaskStartScheduler(). As far as my debug tool says is: “Target halted due to Software Breakpoint in user code”. I provide test code: Empty main function, no interrupts enabled, no tasks creatated. In debug mode i place breakpoint inside the idle task tick hook and it breaks many time, but when i run the target, it resets.
Due to this project is migration from PIC24E part, if we manage to stabilize the interrupts and general behavior here, we can port our application level without issues, thanks in advance: The FreeRTOS config and configuration bits remai unchanged.
void main(void)
{
// Enable the pre-fetch cache module to achieve 100MHz Tcy:
CHECON = 0b00000000000000000000001100110010;