新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > STM32 RTC測試成功 _只顯示 時(shí)分秒

        STM32 RTC測試成功 _只顯示 時(shí)分秒

        作者: 時(shí)間:2016-11-13 來源:網(wǎng)絡(luò) 收藏

        源文件位置 STM32F10x_StdPeriph_Lib_V3.1.2ProjectSTM32F10x_StdPeriph_ExamplesRTCCalendar

        本文引用地址:http://www.104case.com/article/201611/316401.htm

        仔細(xì)閱讀其中的readme
        摘抄如下
        @par How to use it ?
        In order to make the program work, you must do the following :
        - Create a project and setup all project configuration
        - Add the required Library files :
        - stm32f10x_gpio.c
        - stm32f10x_rcc.c
        - stm32f10x_rtc.c
        - stm32f10x_bkp.c
        - stm32f10x_pwr.c
        - misc.c
        - stm32f10x_usart.c
        - stm32f10x_exti.c
        - system_stm32f10x.c (under LibrariesCMSISCoreCM3)
        - stm32_eval.c (under UtilitiesSTM32_EVAL)
        - Edit stm32f10x.h file to select the device you are working on.
        - Edit stm32_eval.h file to select the evaluation board you will use.

        根據(jù)之前的經(jīng)驗(yàn) 建立工程

        options中建議選上 use microLIB



        現(xiàn)在的時(shí)間,睡覺啦

        程序地址

        RTC測試成功
        轉(zhuǎn)自Tony嵌入式論壇,地址:http://www.cevx.com/bbs/thread-26329-1-1.html

        =========================================================

        關(guān)鍵代碼分析

        /**
        * @brief Returns the time entered by user, using Hyperterminal.
        * @param None
        * @retval Current time RTC counter value
        */
        uint32_t Time_Regulate(void)
        {
        uint32_t Tmp_HH = 0xFF, Tmp_MM = 0xFF, Tmp_SS = 0xFF;

        printf("rn==============Time Settings=====================================");
        printf("rn Please Set Hours");

        while (Tmp_HH == 0xFF)
        {
        Tmp_HH = USART_Scanf(23);//若超級(jí)終端輸入的數(shù)據(jù)大于23,超級(jí)終端提示出錯(cuò)
        }
        printf(": %d", Tmp_HH);
        printf("rn Please Set Minutes");
        while (Tmp_MM == 0xFF)
        {
        Tmp_MM = USART_Scanf(59);
        }
        printf(": %d", Tmp_MM);
        printf("rn Please Set Seconds");
        while (Tmp_SS == 0xFF)
        {
        Tmp_SS = USART_Scanf(59);
        }
        printf(": %d", Tmp_SS);

        /* Return the value to store in RTC counter register */
        return((Tmp_HH*3600 + Tmp_MM*60 + Tmp_SS));
        }

        --------------------------------------

        /**
        * @brief Displays the current time.
        * @param TimeVar: RTC counter value.
        * @retval None
        */
        void Time_Display(uint32_t TimeVar)
        {
        uint32_t THH = 0, TMM = 0, TSS = 0;

        /* Compute hours */
        THH = TimeVar / 3600;
        /* Compute minutes */
        TMM = (TimeVar % 3600) / 60;
        /* Compute seconds */
        TSS = (TimeVar % 3600) % 60;

        printf("Time: %0.2d:%0.2d:%0.2dr", THH, TMM, TSS);//r回車,光標(biāo)移到本行首
        }



        關(guān)鍵詞: STM32RTC測試時(shí)分

        評(píng)論


        技術(shù)專區(qū)

        關(guān)閉
        主站蜘蛛池模板: 垫江县| 读书| 开原市| 蒙阴县| 讷河市| 青神县| 正宁县| 阳曲县| 霸州市| 廊坊市| 宜兴市| 黄浦区| 准格尔旗| 临朐县| 遂平县| 原阳县| 平度市| 驻马店市| 奉新县| 吉木乃县| 四会市| 涟源市| 正定县| 邯郸县| 崇阳县| 元朗区| 湘潭市| 宁强县| 杂多县| 七台河市| 赤水市| 新源县| 呼伦贝尔市| 奉贤区| 凌云县| 信宜市| 思茅市| 盐池县| 根河市| 外汇| 中卫市|