Quality RTOS & Embedded Software

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


Loading

STM32, problem with tickless idle mode

Posted by Jakub on July 19, 2013
Hi,
I try to implement tickless idle mode in STM32F103 as in example configuration at http://www.freertos.org/low-power-tickless-rtos.html I get some good results - it's working, but not exactly as I wanted: the ticks period is about 150ms (I computed that it can be max 233ms with my configuration (CPU core clock 72MHz, SysTick clock -> the same, TickRate 1000Hz)). The additional timer used to generate interrupt is RTC.
These are my implementations of functions from example:

unsigned long ulGetExternalTime(void)
{
/* Wait for RTC registers synchronization */
RTC_WaitForSynchro();
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
return RTC_GetCounter();
}

void prvStopTickInterruptTimer(void)
{
portNVIC_SYSTICK_CTRL_REG &= ~0x00000002;
}

void prvStartTickInterruptTimer(void)
{
RTC_WaitForLastTask();
/* Disable the RTC ALARM */
RTC_ITConfig(RTC_IT_ALR, DISABLE);
/* Wait until last write operation on RTC registers has finished */
//RTC_WaitForLastTask();
portNVIC_SYSTICK_CTRL_REG |= 0x00000002;
}

void vSetWakeTimeInterrupt( portTickType xExpectedIdleTime )
{
RTC_WaitForLastTask();
RTC_ClearFlag(RTC_FLAG_SEC);
while( RTC_GetFlagStatus( RTC_FLAG_SEC ) == RESET )
{
}
RTC_SetAlarm(RTC_GetCounter() + xExpectedIdleTime);
RTC_WaitForLastTask();
/* Enable the RTC Alarm */
RTC_ITConfig(RTC_IT_ALR, ENABLE);
}

Additionally, RTC is clocked with external 32768Hz oscillator, its prescaler is set to 32
Does anybody has any ideas what's wrong?

*sorry for my English, i realize it's not very good

RE: STM32, problem with tickless idle mode

Posted by Jakub on July 19, 2013
I forgot it:
when I changed prvStopTickInterrupt to disable SysTick timer interrupts and disable counter too, the tick period grew to about 30ms.
Apart of them, I can see on the osciloscope that the tick occurs every 150ms but it toggles four times...

RE: STM32, problem with tickless idle mode

Posted by Richard on July 19, 2013
Sorry, I'm not sure what you are saying is wrong. Is it just that the tick period is incorrect (you try to set the tick period to generate a certain frequency, but the frequency achieved is not what you intended)? Or is it something specific to turning the tick on and off that is wrong?

Unfortunately I can't comment on chip or peripheral specific configurations as there are just too many chips and peripherals out there to be familiar with all of them.

Are you trying to use both the SysTick timer and the RTC? So using SysTick during normal operation and the RTC when you turn the tick off?

Regards.

RE: STM32, problem with tickless idle mode

Posted by Jakub on July 19, 2013
Yes, I try to use SysTick during normal operation and the RTC when tick is turn off.
But the problem seems to be with hardware configuration, not with my (mis)understanding of the FreeRTOS :) so i try to deal with it myself.
Thanks

RE: STM32, problem with tickless idle mode

Posted by Jakub on July 22, 2013
hmm, I noticed some strange things:
1) as i said, i've got 2 tasks, both blink led. I don't change any configuration parameters. When I run default implementation of tickless idle mode, the condition
if( eTaskConfirmSleepModeStatus() == eAbortSleep )
is never true. In my implementation (made from example from http://www.freertos.org/low-power-tickless-rtos.html) this condition is true very often.

2. Another strange thing - change of configTICK_RATE_HZ from 1000Hz to 993Hz makes my tickless period (in my own implementation) around 2x longer. And i haven't a clue why...

RE: STM32, problem with tickless idle mode

Posted by Jakub on July 22, 2013
and another thing:
When in function prvStopTickInterruptTimer ( and prvStartTickInterruptTimer ) I only turn off interrupts from SysTick timer the tickless period is 5x longer than when I turn off interrupts and disable a counter too.


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


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner