Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

osDelay() when the Tickless Idle Mode of FreeRTOS

Posted by masahoshi on December 9, 2015

I am trying to use the tickless idle mode using FreeRTOS 8.2.1 on STM32L476G-Discovery.

I am using a task which is blinking the LED for eacxNextTaskUnblockTime of prvGetExpectedIdleTime() was portMAXDELAY, when pass a value to portSUPPRESSTICKSANDSLEEP( xExpectedIdleTime ). h 50ms, and want to confirm that if the action could be maintained in 50ms interval even in the tickless idle mode or not.

The action is confirmed good when release LowPower by Systick interrupt. But when release LowPower by external interrupt, sometimes the action was not expected (means the action could not be maintained in 50ms interval) . ※ External interrupt is assigned the EXIT Line1 Interrupt to Left Botton of Joystick, press many times at irregular intervals.

I checked the output log via UART. xNextTaskUnblockTime of prvGetExpectedIdleTime() was portMAXDELAY, when pass a value to portSUPPRESSTICKSANDSLEEP( xExpectedIdleTime ).

How can I keep the action in a 50ms interval when release LowPower by external interrupt?


osDelay() when the Tickless Idle Mode of FreeRTOS

Posted by rtel on December 9, 2015

If I understand you correctly, then when you use the default Cortex-M tickless idle mode then it is working as expected, but when you use the STM32L specific one you are getting the problem. If my understanding is correct, are you using the STM32L specific implementation found in the FreeRTOS zip file download?

xNextTaskUnblockTime of prvGetExpectedIdleTime() was portMAXDELAY, when pass a value to portSUPPRESSTICKSANDSLEEP( xExpectedIdleTime ).

The portMAXDELAY value should be capped to the maximum possible sleep time (basically the time it takes for the timer to overflow) inside the suppress ticks and sleep function itself. Is the problem that this should be less than or equal to 50ms, rather than portMAXDELAY, before it is passed into the suppress ticks and sleep function? Could you try V8.2.3 version, as some work was done there recently, although as I recall it was only to allow tickless idle when configUSE_PREEMPTION was 0 (which could not be done before).


osDelay() when the Tickless Idle Mode of FreeRTOS

Posted by masahoshi on December 10, 2015

I tried V8.2.3. When configUSEPREEMPTION is 0, the NG behavior occured. When configUSEPREEMPTION is 1, the NG behavior did not occur.

Let me explain something about my test environment. (1)I generated the code in the following set for STM32L476G-DISCO in STM32CubeMX V4.10.1(Firmware Package Name and Version is STM32Cube FWL4 V1.0.0). ・FREERTOS : Enable ・USART2 : Asynchronous ・Assign the EXIT Line1 Interrupt to GPIO PA1 (JoyStick Left Botton) ・FREERTOSのUSEPREEMPTION : Disable or Enable ・FREERTOSのUSETICKLESSIDLE : Enable

(2) Based on the generated code, I added some changes. ・FREERTOS V8.2.1→V8.2.3 ・Add the following code to main.c.

PUTCHARPROTOTYPE { /* Place your implementation of fputc here / / e.g. write a character to the EVALCOM1 and Loop until the end of transmission / HALUARTTransmit(&huart2, (uint8_t *)&ch, 1, 0xFFFF); return ch; } void StartDefaultTask(void const * argument) { / USER CODE BEGIN 5 / uint32_t startTime, endTime; / Infinite loop / for(;;) { HALGPIOTogglePin(GPIOB, GPIOPIN2); startTime = osKernelSysTick(); osDelay(50); endTime = osKernelSysTick(); printf("intvl=%dnr", endTime - startTime); } / USER CODE END 5 */ }

・Add the following code to mxconstants.h. *****#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)

(3) I started this program on the target board, and press quickly many times on the Left Botton of Joystick. When it continued for about 10 minutes and the phenomenon occured. Below is the log of TeraTerm when the phenomenon occured.

[Wed Dec 09 19:30:23.604 2015] intvl=50 [Wed Dec 09 19:30:23.667 2015] intvl=50 [Wed Dec 09 19:30:23.714 2015] intvl=50 [Wed Dec 09 19:30:23.760 2015] intvl=50 [Wed Dec 09 19:30:23.807 2015] intvl=50 [Wed Dec 09 19:30:24.073 2015] intvl=259 [Wed Dec 09 19:30:24.120 2015] intvl=50 [Wed Dec 09 19:30:24.167 2015] intvl=50 [Wed Dec 09 19:30:24.214 2015] intvl=50 [Wed Dec 09 19:30:24.276 2015] intvl=50 [Wed Dec 09 19:30:24.323 2015] intvl=50 … [Wed Dec 09 19:30:35.372 2015] intvl=50 [Wed Dec 09 19:30:35.435 2015] intvl=50 [Wed Dec 09 19:30:35.482 2015] intvl=50 [Wed Dec 09 19:30:35.700 2015] intvl=218 [Wed Dec 09 19:30:35.747 2015] intvl=50 [Wed Dec 09 19:30:35.794 2015] intvl=50 [Wed Dec 09 19:30:35.841 2015] intvl=50 [Wed Dec 09 19:30:35.888 2015] intvl=50 [Wed Dec 09 19:30:35.950 2015] intvl=50


osDelay() when the Tickless Idle Mode of FreeRTOS

Posted by rtel on December 10, 2015

Looking at the change history I see I made a mistake in my last post. The changes to support tickless idle when configUSE_PREEMPTION is 0 are not in V8.2.3, but in the head revision (in the public SVN repository)

http://www.freertos.org/History.txt

Is the log you show taken with configUSE_PREEMPTION set to 0?


osDelay() when the Tickless Idle Mode of FreeRTOS

Posted by masahoshi on December 10, 2015

I changed to use the latest FREERTOS revision (freertos-code-2396-trunk). And the abnormal behavior no longer occurred when configUSE_PREEMPTION is 0.

I really appreciate you very much.

For reference! In the below line of port.c 604 Line: configPRESLEEPPROCESSING (xModifiableIdleTime) 611 Line: configPOSTSLEEPPROCESSING (xExpectedIdleTime) There is a compile error because of no "&".


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS