Posted on June 19, 2014 at 17:40HI, i want to configure the RTC alarm with LCD, to goal is to display the time in a LCD. I set the LCD and RTC but I do not know commant display the time on the LCD
This is my code to configure the RTC alarm
- void RTC_Config(void)
- {
- RTC_TimeTypeDef RTC_TimeStructure;
- RTC_InitTypeDef RTC_InitStructure;
- /* Enable the PWR clock */
- RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
- /* Allow access to RTC */
- //PWR_BackupAccessCmd(ENABLE);
- /* Reset RTC Domain */
- RCC_BackupResetCmd(ENABLE);
- RCC_BackupResetCmd(DISABLE);
- /* Enable the LSE OSC */
- RCC_LSEConfig(RCC_LSE_ON);
- /* Wait till LSE is ready */
- while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
- {
- }
- /* Select the RTC Clock Source */
- RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
- /* Define the RCC with hours */
- RTC_InitStructure.RTC_AsynchPrediv = 0x7F;
- RTC_InitStructure.RTC_SynchPrediv = 0xFF;
- RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
- RTC_Init(&RTC_InitStructure);
-
- /* Define time to 00h 00mn 00s AM */
- RTC_TimeStructure.RTC_H12 = RTC_H12_AM;
- RTC_TimeStructure.RTC_Hours = 0x00; //0 h
- RTC_TimeStructure.RTC_Minutes = 0x00; //0 Minutes
- RTC_TimeStructure.RTC_Seconds = 0x00; // Secands
- RTC_SetTime(RTC_Format_BCD, &RTC_TimeStructure);
-
- }
- void RTC_AlarmConfig(void)
- {
- EXTI_InitTypeDef EXTI_InitStructure;
- RTC_AlarmTypeDef RTC_AlarmStructure;
- NVIC_InitTypeDef NVIC_InitStructure;
-
- /* EXTI configuration */
- EXTI_ClearITPendingBit(EXTI_Line17);
- EXTI_InitStructure.EXTI_Line = EXTI_Line17;
- EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
- EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
- EXTI_InitStructure.EXTI_LineCmd = ENABLE;
- EXTI_Init(&EXTI_InitStructure);
-
- /* Enable the RTC Alarm Interrupt */
- NVIC_InitStructure.NVIC_IRQChannel = RTC_Alarm_IRQn;
- NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
- NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
- NVIC_Init(&NVIC_InitStructure);
-
- /* Set the alarmA Masks */
- RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_All;
- RTC_SetAlarm(RTC_Format_BCD, RTC_Alarm_A, &RTC_AlarmStructure);
-
- /* Set AlarmA subseconds and enable SubSec Alarm : generate 8 interripts per Second */
- RTC_AlarmSubSecondConfig(RTC_Alarm_A, 0xFF, RTC_AlarmSubSecondMask_SS14_5);
- /* Enable AlarmA interrupt */
- RTC_ITConfig(RTC_IT_ALRA, ENABLE);
- }