• 【iCore4 双核心板_ARM】例程十:RTC实时时钟实验——显示时间和日期


    实验现象:

    核心代码:

    int main(void)
    {
      /* USER CODE BEGIN 1 */
        RTC_TimeTypeDef sTime;
      RTC_DateTypeDef sDate;
        int second_bak = 0;
        
      /* USER CODE END 1 */
    
      /* MCU Configuration----------------------------------------------------------*/
    
      /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
      HAL_Init();
    
      /* USER CODE BEGIN Init */
    
      /* USER CODE END Init */
    
      /* Configure the system clock */
      SystemClock_Config();
    
      /* USER CODE BEGIN SysInit */
    
      /* USER CODE END SysInit */
    
      /* Initialize all configured peripherals */
      MX_GPIO_Init();
      MX_RTC_Init();
      MX_USART6_UART_Init();
    
      /* USER CODE BEGIN 2 */
        usart6.initialize(115200);                                                                                        //´®¿Ú²¨ÌØÉèÖÃ
        usart6.printf("x0c");                                                                                              //ÇåÆÁ
        usart6.printf("33[1;32;40m");                                       //ÉèÖÃÖÕ¶Ë×ÖÌåΪÂÌÉ«
        usart6.printf(" Hello, I am iCore4!
    ");                                                        //´®¿ÚÐÅÏ¢Êä³ö 
        LED_GREEN_ON;
        
        //ÉèÖÃRTCÈÕÆÚºÍʱ¼ä
        my_rtc.set_date(17,8,11,5);
        my_rtc.set_time(17,43,20);
      /* 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_bak != sTime.Seconds){
                usart6.printf(" %02d:%02d:%02d  ",sTime.Hours,sTime.Minutes,sTime.Seconds);
                usart6.printf("20%02d-%02d-%02d  
    ",sDate.Year,sDate.Month,sDate.Date);
                second_bak = sTime.Seconds;                
            }
      }
      /* USER CODE END 3 */
    
    }

    源代码下载链接:

    链接:http://pan.baidu.com/s/1pLJn3HT 密码:gjwl

    iCore4链接:

  • 相关阅读:
    企业版证书打包APP发布,安装后闪退问题解决。
    Swift 与 Object-C 交互 (Swift版本为:1.2)
    iOS开发-代码片段(Code Snippets)提高开发效率
    iOS开发-Object-C可变参数函数
    MAC-Zsh安装与使用——终极Shell
    Git-学习笔记(常用命令集合)
    CSS动画,2D和3D模块
    CSS定位与布局
    CSS基础
    CSS概述
  • 原文地址:https://www.cnblogs.com/xiaomagee/p/7402624.html
Copyright © 2020-2023  润新知