2016-10-19 11:16 PM
Dear All,
I have implemented stm32f0 rtc application for spending some time in a operation system, kindly take a look and figure-out my mistake, static void MX_RTC_Init(void) { RTC_TimeTypeDef sTime; RTC_DateTypeDef sDate; RTC_AlarmTypeDef sAlarm; /**Initialize RTC and set the Time and Date */ hrtc.Instance = RTC; hrtc.Init.HourFormat = RTC_HOURFORMAT_24; hrtc.Init.AsynchPrediv = 127; hrtc.Init.SynchPrediv = 255; hrtc.Init.OutPut = RTC_OUTPUT_DISABLE; hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; if (HAL_RTC_Init(&hrtc) != HAL_OK) { Error_Handler(); } sTime.Hours = 0x0; sTime.Minutes = 0x0; sTime.Seconds = 0x0; sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE; sTime.StoreOperation = RTC_STOREOPERATION_RESET; if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK) { Error_Handler(); } /**Enable the Alarm A */ sAlarm.AlarmTime.Hours = 0x0; sAlarm.AlarmTime.Minutes = 0x0; sAlarm.AlarmTime.Seconds = 0x0; sAlarm.AlarmTime.SubSeconds = 0x0; sAlarm.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE; sAlarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET; sAlarm.AlarmMask = RTC_ALARMMASK_NONE; sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_ALL; sAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE; sAlarm.AlarmDateWeekDay = 1; sAlarm.Alarm = RTC_ALARM_A; if (HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BCD) != HAL_OK) { Error_Handler(); } /**Enable the WakeUp */ if (HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0, RTC_WAKEUPCLOCK_RTCCLK_DIV8) != HAL_OK) { Error_Handler(); } } void EXTI0_IRQHandler(void) { int i; i = 1; } if (EXTI_GetITStatus(EXTI_Line17) != RESET){ } for (GPIO_KEY_SW2==1) {// pressed for enter stand bay state 1 HAL_GPIO_TogglePin (GPIOB, BCD_A_Pin, BCD_B_Pin, BCD_C_Pin, BCD_D_Pin ); HAL_Delay(100); } for (GPIO_KEY_SW4==0) {// pressing SW4 key in rising step (db_count = 16) EXTI->PR = 0x00000200; RTC->WPR = 0xCA; GPIOC ->IDR & GPIO_IDR_0 GPIOC ->ODR |= (1<<14) { i=0; while(i<16) // { i++; } /* Clear interrupt flag */ RTC->WPR = 0xFE; EXTI_ClearITPendingBit(EXTI_Line17); } }void EXTI19_IRQHandler(void) { /* Make sure that interrupt flag is set */ if (EXTI_GetITStatus(EXTI_Line19) != RESET) { for (GPIO_KEY_SW3==0) {// pressing SW4 key in falling step (db_count = 16) EXTI->PR = 0x00000200; GPIOC ->IDR & GPIO_IDR_0 RTC->WPR = 0xCA; GPIOC ->ODR |= (1<<14) { i=0; while(i<16) // { i--; /* Clear interrupt flag */ RTC->WPR = 0xFE; EXTI_ClearITPendingBit(EXTI_Line19); } } static void RTC_TimeShow(uint8_t* showtime) { RTC_TimeTypeDef sTime; /* Get the RTC current Time */ HAL_RTC_GetTime(&hrtc, & sTime, RTC_FORMAT_BCD); /* Display time Format : hh:mm:ss */ sprintf((char*)showtime,''%02d:%02d:%02d'',sTime.Hours, sTime.Minutes, sTime.Seconds); }2016-10-20 03:05 AM
Hi hasan.md_mubdiul,
TO get help from other user, you need to give more details about your application ; the expected behavior from RTC ? if the application will enter a low power mode and wakeup from it through RTC interrupt ? the operations done in the bottom and RTC interrupt. An anonymous code will note explain the thing. Also , you would mention the device, the hardware used, the version of CubeMx and Cube .-Hannibal-2016-10-20 05:27 PM
Dear Sir Hannibal,
Thank you for your response in my post.Let me explain what you want to know.1. I am expecting a Time setting application from RTC, that will be related to get send spi data (temperature data) to usable GPIO.2. Yes, my application is in low power mode, in the starting point I used, HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1); HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);3. How can I edit this anonymous code ?4. I am using a custom board of STM32F070RB-T6 in STM32cubeMX 4.16.1 version.RegardsHasan