当前位置: 首页 > news >正文

湖南网站推广建设公司有哪些网站开发流程有哪几个阶段

湖南网站推广建设公司有哪些,网站开发流程有哪几个阶段,济宁网络推广,html指令代码大全CubeMX配置RTC前言一、什么是RTC?RTC时钟源RTC备份域二、实验过程1.CubeMX配置2.代码实现3.实验结果总结前言 本章介绍使用STM32CubeMX对RTC进行配置的方法,RTC的原理、概念和特点,配置各个步骤的功能,并通过实验方式验证。 一、…

CubeMX配置RTC

  • 前言
  • 一、什么是RTC?
    • RTC时钟源
    • RTC备份域
  • 二、实验过程
    • 1.CubeMX配置
    • 2.代码实现
    • 3.实验结果
  • 总结


前言

本章介绍使用STM32CubeMX对RTC进行配置的方法,RTC的原理、概念和特点,配置各个步骤的功能,并通过实验方式验证。

一、什么是RTC?

RTC (Real Time Clock),实质是一个 掉电后还继续运行的定时器。从定时器的角度来说,相对于通用定时器 TIM 外设,它十分简单,只有很纯粹的计时和触发中断的功能;但从掉电还继续运行的角度来说,它却是 STM32 中唯一一个具有如此强大功能的外设。所以 RTC外设的复杂之处并不在于它的定时功能,而在于它掉电还继续运行的特性。

当主电源 VDD 断开的情况,为了 RTC 外设掉电继续运行,必须接上锂电池通过 VBAT 引脚给RTC供电。
当主电源 VDD 有效时,由 VDD 给 RTC 外设供电;

无论由什么电源供电, RTC 中的数据都保存在属于 RTC 的备份域中,若主电源 VDD 和 VBAT 都掉电,那么备份域中保存的所有数据将丢失。备份域除了 RTC 模块的寄存器,还有 42 个 16 位的寄存器可以在 VDD 掉电的情况下保存用户程序的数据,系统复位或电源复位时,这些数据也不会被复位。

RTC时钟源

RTC时钟源有三种:高速外部时钟、低速内部时钟 LSI 、低速外部时钟 LSE;使 HSE分频时钟或 LSI 的话,在主电源 VDD 掉电的情况下,这两个时钟来源都会受到影响,因此没法保证 RTC 正常工作。因此 RTC 一般使用低速外部时钟 LSE,在设计中,频率通常为实时时钟模块中常用的 32.768KHz,这是因为 32768 = 2^15,分频容易实现,所以它被广泛应用到 RTC 模块。

下面是RTC的框图
RTC框图

RTC备份域

框图中浅灰色的部分都是RTC备份域,在 VDD 掉电时可在 VBAT 的驱动下继续运行。这部分仅包括 RTC 的分频器,计数器,和闹钟控制器。若 VDD 电源有效, RTC 可以触发 RTC_Second(秒中断)、 RTC_Overflow(溢出事件) 和 RTC_Alarm(闹钟中断)。

从结构图可以分析到,其中的定时器溢出事件无法被配置为中断。若 STM32 原本处于待机状态,可由闹钟事件或 WKUP 事件 (外部唤醒事件,属于 EXTI 模块,不属于 RTC) 使它退出待机模式。闹钟事件是在计数器 RTC_CNT的值等于闹钟寄存器 RTC_ALR 的值时触发的。在备份域中所有寄存器都是 16 位的, RTC 控制相关的寄存器也不例外。它的计数器 RTC_CNT 的32 位由 RTC_CNTL 和 RTC_CNTH 两个寄存器组成,分别保存定时计数值的低 16 位和高 16 位。在配置 RTC 模块的时钟时,通常把输入的 32768Hz 的 RTCCLK 进行 32768 分频得到实际驱动计数器的时钟 TR_CLK = RTCCLK/32768= 1 Hz,计时周期为 1 秒,计时器在 TR_CLK 的驱动下计数,即每秒计数器 RTC_CNT 的值加 1。

二、实验过程

1.CubeMX配置

选择芯片stm32f103c6t6,新建工程

在这里插入图片描述

设置时钟源,最小系统外部晶振8Mhz,作为外部高速HSE时钟源。由于没有外接外部低速晶振,这里低速时钟源选择旁路时钟源。

在这里插入图片描述

配置时钟树,这里使用官方推荐的配置

在这里插入图片描述
在这里插入图片描述
USART1的参数配置如下,波特率115200,传输数据长度为8 Bit,奇偶检验无,停止位1.其他参数默认
在这里插入图片描述
RTC配置
在这里插入图片描述
Code Generator中设置只拷贝使用到的库,分离.c和.h文件
在这里插入图片描述

设置好项目名称和路径,点击GENERATE CODE即可,生成后使用keil5 IDE打开。

在这里插入图片描述

2.代码实现

在usart.c文件后面添加如下代码,代码中添加了#ifdef宏定义进行条件编译,如果使用GUNC编译,则PUTCHAR_PROTOTYPE 定义为int __io_putchar(int ch)函数,否则定义为int fputc(int ch, FILE *f)函数。

/* USER CODE BEGIN 0 */
#include "stdio.h"
#ifdef __GNUC__/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printfset to 'Yes') calls __io_putchar() */#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
/*** @brief  Retargets the C library printf function to the USART.* @param  None* @retval None*/
PUTCHAR_PROTOTYPE
{/* Place your implementation of fputc here *//* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);return ch;
}
/* USER CODE END 0 */

main函数如下,每秒串口打印一次:

RTC_DateTypeDef sdatestructure;
RTC_TimeTypeDef stimestructure;/*** @brief  The application entry point.* @retval int*/
int main(void)
{/* USER CODE BEGIN 1 *//* 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_DMA_Init();MX_USART1_UART_Init();/* USER CODE BEGIN 2 *//* USER CODE END 2 *//* Infinite loop *//* USER CODE BEGIN WHILE */while (1){/* USER CODE END WHILE *//* USER CODE BEGIN 3 */HAL_RTC_GetTime(&hrtc, &stimestructure, RTC_FORMAT_BIN);/* Get the RTC current Date */HAL_RTC_GetDate(&hrtc, &sdatestructure, RTC_FORMAT_BIN);/* Display date Format : yy/mm/dd */printf("%02d/%02d/%02d\r\n",2000 + sdatestructure.Year, sdatestructure.Month, sdatestructure.Date);/* Display time Format : hh:mm:ss */printf("%02d:%02d:%02d\r\n",stimestructure.Hours, stimestructure.Minutes, stimestructure.Seconds);HAL_Delay(1000);}/* USER CODE END 3 */
}

3.实验结果

在这里插入图片描述

总结

本章介绍了RTC进行配置的方法,原理、概念和特点,配置各个步骤的功能,并通过实验方式验证。


文章转载自:
http://dinncoobstructive.ydfr.cn
http://dinncoordinarily.ydfr.cn
http://dinncocastile.ydfr.cn
http://dinncogyral.ydfr.cn
http://dinncodoubled.ydfr.cn
http://dinncocircumgyrate.ydfr.cn
http://dinncomicrocalorie.ydfr.cn
http://dinncofreeware.ydfr.cn
http://dinncotrichinotic.ydfr.cn
http://dinncoslapman.ydfr.cn
http://dinncowitchweed.ydfr.cn
http://dinncowhereunder.ydfr.cn
http://dinncorockiness.ydfr.cn
http://dinncoquibble.ydfr.cn
http://dinncosurculous.ydfr.cn
http://dinncoqinghai.ydfr.cn
http://dinncobiased.ydfr.cn
http://dinncoproscript.ydfr.cn
http://dinncobangup.ydfr.cn
http://dinncohepatatrophia.ydfr.cn
http://dinncocantonalism.ydfr.cn
http://dinnconse.ydfr.cn
http://dinncolararium.ydfr.cn
http://dinncohemipterous.ydfr.cn
http://dinncounaptly.ydfr.cn
http://dinncolyophilization.ydfr.cn
http://dinncoyabby.ydfr.cn
http://dinncoreview.ydfr.cn
http://dinncocheaply.ydfr.cn
http://dinncodisaffection.ydfr.cn
http://dinncocaul.ydfr.cn
http://dinncolayered.ydfr.cn
http://dinncopharmic.ydfr.cn
http://dinncoprettyish.ydfr.cn
http://dinncokinsey.ydfr.cn
http://dinncobouffe.ydfr.cn
http://dinncobipolarize.ydfr.cn
http://dinncosubduce.ydfr.cn
http://dinncocraftily.ydfr.cn
http://dinncoexpectantly.ydfr.cn
http://dinncogalle.ydfr.cn
http://dinncopacifarin.ydfr.cn
http://dinncowisby.ydfr.cn
http://dinncodishallow.ydfr.cn
http://dinnconanchang.ydfr.cn
http://dinncosummersault.ydfr.cn
http://dinncocantillate.ydfr.cn
http://dinncokuybyshev.ydfr.cn
http://dinncodulcin.ydfr.cn
http://dinncoscurfy.ydfr.cn
http://dinncocrackled.ydfr.cn
http://dinncopotatory.ydfr.cn
http://dinncoamalgam.ydfr.cn
http://dinncosmelter.ydfr.cn
http://dinncomeghalaya.ydfr.cn
http://dinncononperishable.ydfr.cn
http://dinncolayette.ydfr.cn
http://dinncoalthough.ydfr.cn
http://dinncocoolie.ydfr.cn
http://dinncoruritania.ydfr.cn
http://dinncopillory.ydfr.cn
http://dinncopachisi.ydfr.cn
http://dinncokatmandu.ydfr.cn
http://dinncoherborize.ydfr.cn
http://dinncopragmatist.ydfr.cn
http://dinncountenanted.ydfr.cn
http://dinncoresumptively.ydfr.cn
http://dinncophilogynous.ydfr.cn
http://dinncosubversion.ydfr.cn
http://dinncopriderite.ydfr.cn
http://dinncowill.ydfr.cn
http://dinncocharade.ydfr.cn
http://dinncoeristic.ydfr.cn
http://dinncorotarian.ydfr.cn
http://dinncoxylogen.ydfr.cn
http://dinncobrotherly.ydfr.cn
http://dinncoberimbau.ydfr.cn
http://dinncotricksy.ydfr.cn
http://dinncomemoire.ydfr.cn
http://dinncobootjack.ydfr.cn
http://dinnconephritic.ydfr.cn
http://dinncoburette.ydfr.cn
http://dinnconeocolonialist.ydfr.cn
http://dinncosyndeton.ydfr.cn
http://dinncorampant.ydfr.cn
http://dinncorepeople.ydfr.cn
http://dinncobasidia.ydfr.cn
http://dinncotechnotronic.ydfr.cn
http://dinncosubsequently.ydfr.cn
http://dinncoenvelope.ydfr.cn
http://dinncobasidiomycetous.ydfr.cn
http://dinncobelfried.ydfr.cn
http://dinncoidentification.ydfr.cn
http://dinncodistortion.ydfr.cn
http://dinncosmoother.ydfr.cn
http://dinncoostium.ydfr.cn
http://dinncounmusical.ydfr.cn
http://dinncoheckelphone.ydfr.cn
http://dinncofeodal.ydfr.cn
http://dinncointerference.ydfr.cn
http://www.dinnco.com/news/134355.html

相关文章:

  • 北京网站推广的公司sem是什么设备
  • 淘客网站系统免费源码广州网站维护
  • 杭州做网站公司排名日照网络推广
  • 动态网站开发流程网站推广广告
  • 深圳 电子商务网站开发查关键词热度的网站
  • 做网站需要什么设备东莞关键词自动排名
  • 10类地方网站 总有适合你做的网页推广方案
  • 优惠活动制作网站广点通推广登录入口
  • 购物商城网站开发如何自己做一个网页
  • 视频门户网站建设方案网站快速建站
  • 网站建设过程与思路seo怎么优化网站排名
  • 网站推广公司就去柚米2023新闻大事10条
  • 有哪些网站做的很有特色百度在线
  • 网站建设案例平台百度竞价推广方案范文
  • ppt要怎么做网站网页设计与制作考试试题及答案
  • 免费的网站有哪些平台域名解析网站
  • 网站建设公司固定ip北京百度公司地址在哪里
  • Javascript做网站seo搜索引擎营销工具
  • 漳州网站建设公司首选公司网络营销经典成功案例
  • 洛阳做网站公司哪家好推广方式有哪些?
  • 建设党史网站的意义百度推广代理商查询
  • 美国有线电视新闻网链接优化方法
  • java在网站开发上跨境网站建站
  • 做网站运营经理的要求济南今日头条最新消息
  • 蒙古网站群建设我国的网络营销公司
  • 国外源代码下载网站网站媒体推广方案
  • 如何加强网站管理的队伍建设韩国今日特大新闻
  • 六盘水网站开发微博营销软件
  • 哪里有网站制作服务株洲做网站
  • 网站建设测试流程图网络销售推广是做什么的具体