STM32L152 RTC 读取时间和日期,用串口将时间发送出来,测试了年月日进位都正常。
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 24914 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISCMSIS END USER LICENCE AGREEMENT.pdf
文件 505206 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxIncludestm32l1xx.h
文件 2220 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxIncludesystem_stm32l1xx.h
文件 33403 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxRelease_Notes.html
文件 14803 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesarmstartup_stm32l1xx_hd.s
文件 13020 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesarmstartup_stm32l1xx_md.s
文件 14559 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesarmstartup_stm32l1xx_mdp.s
文件 14729 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesarmstartup_stm32l1xx_xl.s
文件 11998 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesgcc_ride7startup_stm32l1xx_hd.s
文件 10669 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesgcc_ride7startup_stm32l1xx_md.s
文件 11745 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesgcc_ride7startup_stm32l1xx_mdp.s
文件 11909 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesgcc_ride7startup_stm32l1xx_xl.s
文件 17100 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesiarstartup_stm32l1xx_hd.s
文件 14563 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesiarstartup_stm32l1xx_md.s
文件 16502 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesiarstartup_stm32l1xx_mdp.s
文件 16918 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesiarstartup_stm32l1xx_xl.s
文件 20175 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatessystem_stm32l1xx.c
文件 3686 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesTASKINGcstart_thumb2.asm
文件 12064 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesTrueSTUDIOstartup_stm32l1xx_hd.s
文件 10737 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesTrueSTUDIOstartup_stm32l1xx_md.s
文件 11806 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesTrueSTUDIOstartup_stm32l1xx_mdp.s
文件 11975 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesTrueSTUDIOstartup_stm32l1xx_xl.s
文件 11118 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDocumentationCorehtmlannotated.html
文件 1082 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDocumentationCorehtmlannotated.js
文件 671 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDocumentationCorehtmlc_s.png
文件 147 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDocumentationCorehtmldwn.png
文件 922 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDocumentationCorehtmlcheck.png
文件 11104 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDocumentationCorehtmlclasses.html
文件 132 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDocumentationCorehtmlclosed.png
文件 20532 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDocumentationCorehtmlcmsis.css
............此处省略1036个文件信息
/******************** (C) COPYRIGHT 2016 ZhouJun ******************************
* File Name : main.c
hardware : STM32L152
* Author : ZhouJun
* Version : V1.0
* Date : 20161120
* Description : 药品追溯项目主函数
********************************************************************************/
/*--------------------------- 头文件包含 --------------------------------------*/
#include “main.h“
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
void SysTickConfig(void);
//毫秒级的延时
static void Delay_ms(u16 time)
{
u16 i=0;
while(time--)
{
// i=12000*4/9; //自己定义72M时为10,32M时为4/9
// i=12000*10/27;
i=4576; //用秒表调试出来10s为10.03,要更准确就用示波器测
while(i--);
}
}
/* Private functions ---------------------------------------------------------*/
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
RTC_TimeTypeDef tempRTC_TimeStructure; //RTC时间临时变量
/*!< At this stage the microcontroller clock setting is already configured
this is done through SystemInit() function which is called from startup
file (startup_stm32l1xx_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function refer to
system_stm32l1xx.c file
*/
/* RTC configuration -------------------------------------------------------*/
RTC_Config();
InitKeyGpio();
//SX1278
// RFInit(); //射频模块初始化
// //RFRxMode(); //进入接收模式
// RFM96_Config(0); //处于待机模式待机模式1.8mA
// RFM96_Sleep();
USART_Config(); //串口设置
/* Set the time to 01h 00mn 00s AM */
SetDateTime(); //设置日期时间
RTC_GetTime(RTC_Format_BIN &RTC_TimeStructure); //得先读时间,再读日期
RTC_GetDate(RTC_Format_BIN &RTC_DateStructure);
USART3_SendChar(RTC_DateStructure.RTC_Year); //年
USART3_SendChar(RTC_DateStructure.RTC_Month); //月
USART3_SendChar(RTC_DateStructure.RTC_Date); //日
USART3_SendChar(RTC_TimeStructure.RTC_Hours); //时
USART3_SendChar(RTC_TimeStructure.RTC_Minutes); //分
USART3_SendChar(RTC_TimeStructure.RTC_Seconds); //秒
USART3_SendChar(‘
‘);
USART3_SendChar(‘
‘);
while(1)
{
Delay_ms(1000);
RTC_GetTime(RTC_Format_BIN &RTC_TimeStructure); //得先读时间,再读日期
RTC_GetDate(RTC_Format_BIN &RTC_DateStructure);
USART3_SendChar(RTC_DateStructure.RTC_Year); //年
USART3_SendChar(RTC_DateStructure.RTC_Month); //月
USART3_SendChar(RTC_DateStructure.RTC_Date); //日
USART3_SendChar(RTC_TimeStructure.RTC_Hours); //时
USART3_SendChar(RTC_TimeStructure.RTC_Minutes); //分
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 24914 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISCMSIS END USER LICENCE AGREEMENT.pdf
文件 505206 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxIncludestm32l1xx.h
文件 2220 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxIncludesystem_stm32l1xx.h
文件 33403 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxRelease_Notes.html
文件 14803 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesarmstartup_stm32l1xx_hd.s
文件 13020 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesarmstartup_stm32l1xx_md.s
文件 14559 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesarmstartup_stm32l1xx_mdp.s
文件 14729 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesarmstartup_stm32l1xx_xl.s
文件 11998 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesgcc_ride7startup_stm32l1xx_hd.s
文件 10669 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesgcc_ride7startup_stm32l1xx_md.s
文件 11745 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesgcc_ride7startup_stm32l1xx_mdp.s
文件 11909 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesgcc_ride7startup_stm32l1xx_xl.s
文件 17100 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesiarstartup_stm32l1xx_hd.s
文件 14563 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesiarstartup_stm32l1xx_md.s
文件 16502 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesiarstartup_stm32l1xx_mdp.s
文件 16918 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesiarstartup_stm32l1xx_xl.s
文件 20175 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatessystem_stm32l1xx.c
文件 3686 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesTASKINGcstart_thumb2.asm
文件 12064 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesTrueSTUDIOstartup_stm32l1xx_hd.s
文件 10737 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesTrueSTUDIOstartup_stm32l1xx_md.s
文件 11806 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesTrueSTUDIOstartup_stm32l1xx_mdp.s
文件 11975 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常CMSISDeviceSTSTM32L1xxSourceTemplatesTrueSTUDIOstartup_stm32l1xx_xl.s
文件 11118 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDocumentationCorehtmlannotated.html
文件 1082 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDocumentationCorehtmlannotated.js
文件 671 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDocumentationCorehtmlc_s.png
文件 147 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDocumentationCorehtmldwn.png
文件 922 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDocumentationCorehtmlcheck.png
文件 11104 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDocumentationCorehtmlclasses.html
文件 132 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDocumentationCorehtmlclosed.png
文件 20532 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常CMSISDocumentationCorehtmlcmsis.css
............此处省略1036个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)