cancel
Showing results for 
Search instead for 
Did you mean: 

Using RTC Wake up ISR as OS Systick

mgoharlaee
Associate
Posted on April 05, 2016 at 21:48

Due to low power requirements, I would like to use a different source to generate the 1ms or 10ms OS tick. The internal RTC, using a 32768Hz external crystal as it's clock source, is able to generate interrupts at ~61us increments if the wake up ISR is setup to auto interrupt periodically. In our STM32L152xD device, I was able to setup the interrupt and see that it jumps to the ISR, but it seems it is happening a lot faster that expected based on the Asynchronous/Synchronous pre-scaler registers.  What values would I need to write to these registers to get a 1ms interrupt? I programmed them with 2, and 10 to give (2+1)*(10+1) = 33, then 32768/33 = ~993 Hz. I declared a unsigned long variable which is incremented each time interrupt takes place, but the values I read after placing a break point in the code are in the millions! Not even possible in the lowest interval of 63us. The WUTF bit in the RTC->ISR register is cleared in the ISR as the first line of code.

Any suggestions?

Thanks

Galan

#stm32l152-rtc-configuration
1 REPLY 1
Walid FTITI_O
Senior II
Posted on April 15, 2016 at 17:25

Hi goharlaee.mano.002,

As mentioned in the application note

http://www.st.com/web/en/resource/technical/document/application_note/DM00025071.pdf

''Using the hardware real time clock (RTC)'' :

The minimum wakeup period that you can get is 122,07 us.

But there is no need for RTC in your case ! To use clock other than SysTick to generate the tick interrupt you ought to generate ab interrupt from a timer other than Systick:
  • Provide an implementation of vPortSetupTimerInterrupt() that generates an interrupt at the frequency specified by the configTICK_RATE_HZ FreeRTOSConfig.h constant.

  • Install xPortSysTickHandler() as the handler for the timer interrupt, and ensure xPortSysTickHandler() is not mapped to SysTick_Handler() in FreeRTOSConfig.h, or renamed as SysTick_Handler() in port.c.

This is mentioned in the

http://www.st.com/st-web-ui/static/active/jp/resource/technical/document/user_manual/DM00105262.pdf

: “Developing Applications on STM32Cube With RTOS�

Another information , if you need to use other HAL time base than Systick and keep Systick as only FreeRtos Timer base ( to prevent dead lock issue) you ought to select a timer as HAL time base source. Refer to ''HAL_TimeBase'' example in

http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/LN1897/PF259243

at this path:

STM32Cube_FW_F4_V1.11.0\Projects\STM32469I_EVAL\Examples\HAL\HAL_TimeBase

(You can do that using

http://www2.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-configurators-and-code-generators/stm32cubemx.html

platform, in SYS table -> Timerbase Source )

-Hannibal-