zoukankan      html  css  js  c++  java
  • 【iCore1S 双核心板_ARM】例程十一:RTC实时时钟实验——显示时间和日期

    实验现象:

    核心代码:

    int main(void)
    {
    
      /* USER CODE BEGIN 1 */
            RTC_DateTypeDef sDate;
            RTC_TimeTypeDef sTime;
            uint8_t second_tmp = 0;
      /* USER CODE END 1 */
    
      /* MCU Configuration----------------------------------------------------------*/
    
      /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
      HAL_Init();
    
      /* Configure the system clock */
      SystemClock_Config();
    
      /* Initialize all configured peripherals */
      MX_GPIO_Init();
      MX_RTC_Init();
      MX_USART1_UART_Init();
      SystemClock_Config();
    
      /* USER CODE BEGIN 2 */
        LED_RED_ON;                                                                                             //ºìµÆ³£ÁÁ
        usart1.printf("x0c");                                   //ÇåÆÁ    
        usart1.printf("33[1;32;40m");                          //ÉèÖÃ×ÖÌåÖÕ¶ËΪÂÌÉ«
        usart1.printf("
    
    hello! I am iCore1S!
    
    
    ");
    
      /* USER CODE END 2 */
    
      /* Infinite loop */
      /* USER CODE BEGIN WHILE */
      while (1)
      {
      /* USER CODE END WHILE */
    
      /* USER CODE BEGIN 3 */
          HAL_Delay(100);                                                                                 //¶ÁÈ¡RTCÈÕÆÚºÍʱ¼ä
            HAL_RTC_GetTime(&hrtc, &sTime, RTC_FORMAT_BIN);
            HAL_RTC_GetDate(&hrtc, &sDate, RTC_FORMAT_BIN);
            
            if(second_tmp != sTime.Seconds){                                           //µ±ÃëÊý¾ÝÓ뱸·Ý²»Ò»ÖÂʱ£¬ÏòÖն˴òӡʱ¼ä/ÈÕÆÚ
    
                usart1.printf("  %02d:%02d:%02d  ",sTime.Hours,sTime.Minutes,sTime.Seconds);
                usart1.printf("20%02d-%02d-%02d  
    ",sDate.Year,sDate.Month,sDate.Date);
                second_tmp = sTime.Seconds;                                   //ÃëÊý¾Ý±¸·Ý
            }
    
      }
      /* USER CODE END 3 */
    
    }

    源代码下载链接:

    链接:http://pan.baidu.com/s/1b1hxF4 密码:pg08

  • 相关阅读:
    取石子(五)(FIB博弈)
    NYOJ-161-取石子 (四)(Wythoff 博弈)
    memcached简介
    RSA---应用最广泛的非对称加密算法
    分区
    按子组收集数据
    多级分组
    归约和汇总
    收集器Collectors
    由函数生成流---创建无限流:Stream.iterate和Stream.generate
  • 原文地址:https://www.cnblogs.com/xiaomagee/p/7452871.html
Copyright © 2011-2022 走看看