资源简介
STM32L152 RTC 读取时间和日期,用串口将时间发送出来,测试了年月日进位都正常。
代码片段和文件信息
/******************** (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(‘\r‘);
USART3_SendChar(‘\n‘);
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-年月日时分秒正常\CMSIS\CMSIS END USER LICENCE AGREEMENT.pdf
文件 505206 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Include\stm32l1xx.h
文件 2220 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Include\system_stm32l1xx.h
文件 33403 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Release_Notes.html
文件 14803 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\arm\startup_stm32l1xx_hd.s
文件 13020 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\arm\startup_stm32l1xx_md.s
文件 14559 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\arm\startup_stm32l1xx_mdp.s
文件 14729 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\arm\startup_stm32l1xx_xl.s
文件 11998 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\gcc_ride7\startup_stm32l1xx_hd.s
文件 10669 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\gcc_ride7\startup_stm32l1xx_md.s
文件 11745 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\gcc_ride7\startup_stm32l1xx_mdp.s
文件 11909 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\gcc_ride7\startup_stm32l1xx_xl.s
文件 17100 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\iar\startup_stm32l1xx_hd.s
文件 14563 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\iar\startup_stm32l1xx_md.s
文件 16502 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\iar\startup_stm32l1xx_mdp.s
文件 16918 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\iar\startup_stm32l1xx_xl.s
文件 20175 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\system_stm32l1xx.c
文件 3686 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\TASKING\cstart_thumb2.asm
文件 12064 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\TrueSTUDIO\startup_stm32l1xx_hd.s
文件 10737 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\TrueSTUDIO\startup_stm32l1xx_md.s
文件 11806 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\TrueSTUDIO\startup_stm32l1xx_mdp.s
文件 11975 2015-04-20 18:56 10-PWR-RTC-年月日时分秒正常\CMSIS\Device\ST\STM32L1xx\Source\Templates\TrueSTUDIO\startup_stm32l1xx_xl.s
文件 11118 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常\CMSIS\Documentation\Core\html\annotated.html
文件 1082 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常\CMSIS\Documentation\Core\html\annotated.js
文件 671 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常\CMSIS\Documentation\Core\html\bc_s.png
文件 147 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常\CMSIS\Documentation\Core\html\bdwn.png
文件 922 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常\CMSIS\Documentation\Core\html\check.png
文件 11104 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常\CMSIS\Documentation\Core\html\classes.html
文件 132 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常\CMSIS\Documentation\Core\html\closed.png
文件 20532 2015-04-20 14:15 10-PWR-RTC-年月日时分秒正常\CMSIS\Documentation\Core\html\cmsis.css
............此处省略1036个文件信息
- 上一篇:仿qq界面 qt
- 下一篇:镭波F660 BIOS
相关资源
- 基于stm32的闹钟rtc
- STM32L152数据手册_中文.pdf
- STM32+RTCDS1302实时时钟设计,整个工程
- PSOC 官方例程 赛普拉斯 RTC 实时时钟
- STM32F030使用HAL库做低功耗
- STM32MINI RTC闹钟 USMART调试时间
- MSP432RTC实时时钟OLED显示
- webRTC+socketio+SpringBoot视频及文字聊天
- 飞思卡尔智能车入门资料大全.7z
- WebRtc视频聊天demo包括多人聊天
- 数控五轴机床调试步骤
- STM32Cube RTC 万年历方式
- STM32-UCOSIII实战-----RTC+DHT11+按键+LCD显示
- RTCA-DO-160F 机载设备的环境条件和测试
- PowerTCP Telnet for .NET v1.0.3.rar内含注册机
- WebRTC自带的peerconenction Windows版本
- WebRTC零基础开发者教程
- STM32的RTC闹钟实验
- STM32F103驱动ILI9341DS18B20RTCADCIRED
- RtspRtcpRtpLoad_h264.tar.gz
- 简单的RTSP RTP RTCP推送H264码流服务器实
- STM32F030低功耗 定时5分钟 RTC唤醒
- rtc4打标卡sdk
- 乐鑫Esp32实现smartConfig和微信airKiss,一
- 基于NONOS_SDK动手做个8266毕设小案例,
- 8266的SmartConfig与Airkiss一键配网的Dem
- STM32 RTC 万年历 3.2寸TFT液晶显示
- STM32F103C8T6按键调整参数断电保护,温
- RTCM3.2标准
- Learning WebRTC 无水印pdf
评论
共有 条评论