2013-04-28 02:08 PM
Hello
I am trying to setup he alarim to wakeup my MCU from standby everyday at 12:00 but it seems that some times the alarm nor occurs and some it occurs .. what i miss in my code?RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);
//RTC_GetDate(RTC_Format_BIN,&RTC_DateStructure);
/* Set the alarm to current time + 5s */
RTC_AlarmStructure.RTC_AlarmTime.RTC_H12 = RTC_H12_PM;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours =12;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes =0;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds = 0;
RTC_AlarmStructure.RTC_AlarmDateWeekDay = 1;
RTC_AlarmStructure.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date;
RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_DateWeekDay;
RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure);
/* Enable RTC Alarm A Interrupt: this Interrupt will wake-up the system from
STANDBY mode (RTC Alarm IT not enabled in NVIC) */
RTC_ITConfig(RTC_IT_ALRA, ENABLE);
/* Enable the Alarm A */
RTC_AlarmCmd(RTC_Alarm_A, ENABLE);
/* Clear RTC Alarm Flag */
RTC_ClearFlag(RTC_FLAG_ALRAF);
//-----------------------------------------------
for(i=0;i<0xffffff;i++);
PWR_WakeUpPinCmd(ENABLE);
/* Request to enter STANDBY mode (Wake Up flag is cleared in PWR_EnterSTANDBYMode function) */
PWR_EnterSTANDBYMode();
here the start of my code :
RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
RTC_ITConfig(RTC_IT_ALRA, DISABLE);
if(RTC_GetITStatus(RTC_IT_ALRA)==1)
{
wake_flag=1;
RTC_ClearFlag(RTC_FLAG_ALRAF);
}
else
{
wake_flag=0;
}
The second problem that i could not find its solution is :
#define r77 0f
#define r78 0f
#define rtotal r77+r78
#define vref 3.0f
unsigned short temp;
float volt,vbat;
temp=read_battery();//adc
volt= (float)temp * vref;
volt= volt/4094;
vbat = (rtotal* volt);
rtotal must be 85 but it get very diffirent valuels
for debug i used a float RR=rtotal i can see very diffirent value here ..diffirent from
what is wrong here ?
Thank you in advanced
Esat
2013-04-28 07:11 PM
STANDBY exits via a RESET, the start up code, and the RTC initialization code need special handling. You need to provide a more clear and concise example, rather than random code fragments. Why is there an odd timing delay there?
Again, absent some clear test case values and examples, I'm not sure what the issue is with the second case you presented. I'd probably use 4096.0f for the divisor given the 0..4095 range of the 12-bit value.2013-04-29 02:21 AM
2013-04-29 07:51 AM
Hello Esat,
If you are in the same conditions as stated in this [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Leaving%20Standby%20by%20WakeUp%20pin%20and%20RTC%20Alarm&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=497]thread, you have to apply the workaround described by STOne-32 to leave standby mode using RTC alarm. Regards, ST.MCUTo give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2013-04-30 12:32 AM