FreeRTOS and Jennic JN5139 (sleep modes)

Hi I made little test with FreeRTOS and Jennic. I made one task which is run periodically. It does nothing but UART print. If I make the delay by going to sleep, and after wakeup try to start scheduler – nothing happens. Okay, I tried another test. After wakeup I create same task(same name), and then start the scheduler. Program printf’s two line – then dies… Have anyone else similar problems? I think I use correct sleep functions (RAM is not powered off..) because program can read and print variables after wakeup and those have same values like before sleep.

FreeRTOS and Jennic JN5139 (sleep modes)

Hi, I’ve never actually tried using sleep mode when running freeRTOS on the JN5139, however here are some things that might be worth trying: - Are you stopping the scheduler before going into sleep mode. I think it would be best to ensure everything is shutdown gracefully before putting the device to sleep. - What happens if you sleep without memory held, does this work any better? If so this might indicate some internal variable(s) need to be reset upon wake up when using the sleep with memory held mode.

FreeRTOS and Jennic JN5139 (sleep modes)

We have tried following scheduler functions before sleep:
1. vTaskSuspendScheduler()
2. vTaskEndScheduler()
3. taskENTER_CRITICAL(); vTaskSuspendAll(); But seems none of them solved the problem.

FreeRTOS and Jennic JN5139 (sleep modes)

Are you shutting down things like the tick timer before you go to sleep? Also are you initialising everything when you wake up, maybe worth copying the initialisation that happens following a cold start? Post some code showing what you are doing if you continue to have problems.

FreeRTOS and Jennic JN5139 (sleep modes)

Okay Here is some code to check out…     int main( void )
    {
      // Initialise stack and hardware interfaces.
      // Start the scheduler.
      vTaskStartScheduler();
      return 0;
    }
 
    void vLCD1(void *pvParameters)
    {
      int flag = 0;
      vJPI_DioSetDirection(0, E_JPI_DIO11_INT);
      vJPI_DioSetPullup(!E_JPI_DIO11_INT, E_JPI_DIO11_INT);       for (;;)
      {
        if (flag)
        {
            flag-;
            vJPI_DioSetOutput(E_JPI_DIO11_INT,0);
        }
        else
        {
            flag++;
            vJPI_DioSetOutput(0,E_JPI_DIO11_INT);
        }
vTaskDelay(1000/portTICK_RATE_MS);
      }
    }
   
void vLCD2(void *pvParameters)
    {
int flag = 0;
vJPI_DioSetDirection(0, E_JPI_DIO12_INT);
vJPI_DioSetPullup(!E_JPI_DIO12_INT, E_JPI_DIO12_INT);
for (;;)
{
if (flag)
{
flag-;
vJPI_DioSetOutput(E_JPI_DIO12_INT,0);
}
else
{
flag++;
vJPI_DioSetOutput(0,E_JPI_DIO12_INT);
}
vTaskDelay(2000/portTICK_RATE_MS);
}
} void AppColdStart( void )
{
u32AppQApiInit( 0, 0, 0 );
u32AHI_Init();
vInitUart(E_AHI_UART_0);
vPrintString(E_AHI_UART_0, “Coldstart”);
sMacAddr = *(MAC_ExtAddr_s *)pvAppApiGetMacAddrLocation();      
vInitRadio(); xTaskCreate(vLCD1,(signed portCHAR *)&”LCD 1″, configMINIMAL_STACK_SIZE, NULL, 2, NULL);
xTaskCreate(vLCD2,(signed portCHAR *)&”LCD 2″, configMINIMAL_STACK_SIZE, NULL, 2, NULL);
main();
} void AppWarmStart( void )
{
u32AHI_Init();
vInitUart(E_AHI_UART_0);
vAppApiRestoreMacSettings();
vPrintString(E_AHI_UART_0, “Warmstart”);
//xTaskResumeAll(); taskEXIT_CRITICAL();
xTaskResumeScheduler();
//main();
while(1);
} void vSyncSleep(uint32 u32st)         // sleep time in milliseconds
{
uint32 u32calib;
//vAHI_MemoryHold(TRUE);
vAppApiSaveMacSettings();       // save the MAC settings
vAHI_WakeTimerEnable(E_AHI_WAKE_TIMER_0, TRUE);
u32calib = u32AHI_WakeTimerCalibrate();
vAHI_WakeTimerStart(E_AHI_WAKE_TIMER_0, 320000/u32calib*u32st);       //(10000/u32WTCalib)*32000*5);
vAHI_Sleep(E_AHI_SLEEP_OSCON_RAMON);
}