AnsweredAssumed Answered

STM32f4 RTC Alarm with LCD

Question asked by claude.antoine on Jun 19, 2014
Latest reply on Jun 24, 2014 by Trev
HI, 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

       
  1. void RTC_Config(void)
  2.    
  3. {
  4.    
  5.      RTC_TimeTypeDef RTC_TimeStructure;
  6.    
  7. RTC_InitTypeDef RTC_InitStructure;
  8.    
  9.   /* Enable the PWR clock */
  10.    
  11.   RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
  12.    
  13.    
  14.    
  15.   /* Allow access to RTC */
  16.    
  17.   //PWR_BackupAccessCmd(ENABLE);
  18.    
  19.    
  20.    
  21.   /* Reset RTC Domain */
  22.    
  23.   RCC_BackupResetCmd(ENABLE);
  24.    
  25.   RCC_BackupResetCmd(DISABLE);
  26.    
  27.    
  28.    
  29.   /* Enable the LSE OSC */
  30.    
  31.   RCC_LSEConfig(RCC_LSE_ON);
  32.    
  33.    
  34.    
  35.   /* Wait till LSE is ready */  
  36.    
  37.   while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
  38.    
  39.   {
  40.    
  41.   }
  42.    
  43.    
  44.    
  45.   /* Select the RTC Clock Source */
  46.    
  47.   RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
  48.    
  49.    
  50.    
  51.   /* Define the RCC with hours */
  52.    
  53.   RTC_InitStructure.RTC_AsynchPrediv = 0x7F;
  54.    
  55.   RTC_InitStructure.RTC_SynchPrediv  = 0xFF;
  56.    
  57.   RTC_InitStructure.RTC_HourFormat   = RTC_HourFormat_24;
  58.    
  59.   RTC_Init(&RTC_InitStructure);
  60.    
  61.   
  62.    
  63.   /* Define time to 00h 00mn 00s AM */
  64.    
  65.   RTC_TimeStructure.RTC_H12     = RTC_H12_AM;
  66.    
  67.   RTC_TimeStructure.RTC_Hours   = 0x00;  //0 h
  68.    
  69.   RTC_TimeStructure.RTC_Minutes = 0x00;  //0 Minutes
  70.    
  71.   RTC_TimeStructure.RTC_Seconds = 0x00;  // Secands
  72.    
  73.   RTC_SetTime(RTC_Format_BCD, &RTC_TimeStructure);
  74.    
  75.   
  76.    
  77. }
  78.    
  79.    
  80.    
  81.    
  82.    
  83. void RTC_AlarmConfig(void)
  84.    
  85. {
  86.    
  87.   EXTI_InitTypeDef EXTI_InitStructure;
  88.    
  89.   RTC_AlarmTypeDef RTC_AlarmStructure;
  90.    
  91.   NVIC_InitTypeDef NVIC_InitStructure;
  92.    
  93.   
  94.    
  95.   /* EXTI configuration */
  96.    
  97.   EXTI_ClearITPendingBit(EXTI_Line17);
  98.    
  99.   EXTI_InitStructure.EXTI_Line = EXTI_Line17;
  100.    
  101.   EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  102.    
  103.   EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
  104.    
  105.   EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  106.    
  107.   EXTI_Init(&EXTI_InitStructure);
  108.    
  109.   
  110.    
  111.   /* Enable the RTC Alarm Interrupt */
  112.    
  113.   NVIC_InitStructure.NVIC_IRQChannel = RTC_Alarm_IRQn;
  114.    
  115.   NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  116.    
  117.   NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  118.    
  119.   NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  120.    
  121.   NVIC_Init(&NVIC_InitStructure);
  122.    
  123.  
  124.    
  125.   /* Set the alarmA Masks */
  126.    
  127.   RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_All;
  128.    
  129.   RTC_SetAlarm(RTC_Format_BCD, RTC_Alarm_A, &RTC_AlarmStructure);
  130.    
  131.   
  132.    
  133.   /* Set AlarmA subseconds and enable SubSec Alarm : generate 8 interripts per Second */
  134.    
  135.   RTC_AlarmSubSecondConfig(RTC_Alarm_A, 0xFF, RTC_AlarmSubSecondMask_SS14_5);
  136.    
  137.    
  138.    
  139.   /* Enable AlarmA interrupt */
  140.    
  141.   RTC_ITConfig(RTC_IT_ALRA, ENABLE);
  142.    
  143.    
  144.    
  145. }
  146.    

Outcomes