Hello. I’m using FreeRTOS 9.0 with my own implementation of tickless ide mode because there is still not a default one available for the PIC32.
This implementation is based on the example provided here: http://www.freertos.org/low-power-tickless-rtos.html
In my case, the only thing that will wake up the micro from sleep is receiving data through an UART port. In the UART’s ISR, some …ISR() functions are to be called, so the UART interrupt priority is kept below configMAX
SYSCALLINTERRUPT_PRIORITY. Besides, I use the assembly wrapper to call the interrupt handler.
Everything works ok in “normal” mode but, when entering sleep mode, the micro doesn’t wake up when receiving UART data.
In the code I realize that there is a call to “portDISABLE
INTERRUPTS” (in the example code it’s based on, the call is made to “disableinterrupts”). I know it’s necessary due to “…Further, it is necessary for the portSUPPRESS
TICKSAND
SLEEP() function to create a small critical section between the tick source being stopped and the microcontroller entering the sleep state…”
After disabling the interrupts, the micro enters into sleep mode so no interrupt (below configMAXSYSCALL
INTERRUPTPRIORITY) can wake up the micro.
Can the interrupts be safely re-enabled just before entering sleep mode? Otherwise, which available solutions are available to handle this issue?
If I re-enable the interrupts before going to sleep, everything (appears to) work.
This is the part of the code I refer to:
/* Define the function that is called by portSUPPRESS_TICKS_AND_SLEEP(). */
void vApplicationSleep( TickType_t xExpectedIdleTime )
{
unsigned long ulLowPowerTimeBeforeSleep, ulLowPowerTimeAfterSleep;
eSleepModeStatus eSleepStatus;
/* Read the current time from a time source that will remain operational
while the microcontroller is in a low power state. */
ulLowPowerTimeBeforeSleep = ulGetExternalTime();
/* Stop the timer that is generating the tick interrupt. */
prvStopTickInterruptTimer();
** This is where interrupts get disabled **
/* Enter a critical section that will not effect interrupts bringing the MCU
out of sleep mode. */
disable_interrupts();
/* Ensure it is still ok to enter the sleep mode. */
eSleepStatus = eTaskConfirmSleepModeStatus();
if( eSleepStatus == eAbortSleep )
{
/* A task has been moved out of the Blocked state since this macro was
executed, or a context siwth is being held pending. Do not enter a
sleep state. Restart the tick and exit the critical section. */
prvStartTickInterruptTimer();
enable_interrupts();
}
else
{
if( eSleepStatus == eNoTasksWaitingTimeout )
{
** My code always enters here. So it goes to sleep with interrupts disabled **
/* It is not necessary to configure an interrupt to bring the
microcontroller out of its low power state at a fixed time in the
future. */
prvSleep();
}
Thanks in advance.