2014-03-03 08:40 AM
Hello everybody.
I am developing some test firmwares on a STM32F103 based board. After some working programs using the sleep mode, now I need to do some experience with the much more powerful standby mode. I need to set a fixed timer using the RTC in order to wake up the system periodically to perform some tasks. I want to use the RTC, no external interrupts. Can anybody help me with a code example? Thanks in advance2014-03-06 01:42 AM
I am starting from examples but my firmware is not working.
I am using the following code to configure the RTC Alarm with the LSI in order to have an interrupt 3 second after the WFI instruction, but the RTC_AlarmIRQHandler doesn't play NVIC_InitStructure.NVIC_IRQChannel = RTCAlarm_IRQn; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 13; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init( &NVIC_InitStructure ); RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); PWR_BackupAccessCmd(ENABLE); BKP_DeInit(); RCC_LSICmd(ENABLE); /* Enable LSI */ while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET); /* Wait till LSI is ready */ RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI); RCC_RTCCLKCmd(ENABLE); RTC_WaitForSynchro(); RTC_SetPrescaler(32767); RTC_WaitForLastTask(); RTC_ITConfig(RTC_IT_ALR, ENABLE); RTC_WaitForLastTask(); RTC_ClearFlag(RTC_FLAG_SEC); while(RTC_GetFlagStatus(RTC_FLAG_SEC)==RESET); RTC_SetAlarm(RTC_GetCounter()+3); RTC_WaitForLastTask(); __WFI();2014-03-06 02:42 PM
2014-03-07 03:03 AM
There is a missing 'connection' between RTCAlarm and interrupt controller. You need to configure EXTI_Line17 to do so.
2014-03-10 02:07 AM
Thanks a lot, now I am using the standby mode with no problems :)
On the other hand, I have another question: I am measuring the power consumption in standby mode but I am noticing a very variable Idd, from 0.2 to 1mA during the standby period. What about it? What is the cause?2014-03-10 03:12 AM
Hi Emilio,
0.2 mA is so much, in standby mode consumption shouldn't exceed 5µA. If you try just to enter standby mode without RTC configuration for wakeup, what do you get? -Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2014-03-10 03:21 AM
In fact I am logging a really high current consumption for standby mode.
I am using the RTC alarm (with the RTC clock set to use the LSI) to wake up from standby mode.2014-03-10 03:33 AM
Going down to a few µA requires several conditions to be met.
Now that you are running the low power mode, you must check every I/O and make sure every pin has a stable voltage. The most simple is to drive I/O to either 0 (preferable) or 1. When it is not possible to drive as output, input can be selected, either as logical or analog. Of course no resistor shall have ends at different voltage (then sink µA or mA). Don't let any wire to be HI-Z, they act as antenna and make logic to switch and consume a lot of µA.2014-03-10 06:19 AM
input can be selected, either as logical or analog.
Analogue would generally be preferable as in STM32 pin designs it turns off the schmitt trigger on the input. Other vendors suggest driving the pins low, this eliminates a potential for the pin to oscillate. I would try this also, and observe if it improves the current profile. I don't have my notes in front of me, but my recollection is STANDBY takes a couple of uA, I stripped code from the example here that suppresses all the pins. I would examine closely what you have attached to the device pins, and the state of those pins.2014-03-12 04:09 AM
Thanks to both!