You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
978 B
Markdown

2 years ago
# RTC
- 配置System CoreSYSDebug配置为SerialWire
> 因为STM32默认占用PB4等IO作为JTAG引脚
- 可选配置RCCLowSpeedClockLSE配置为Crystal/Ceramic Resonator
- 配置TimersRTC
- Activate Clock Source
- Activate Calendar
- 配置一下初始时间、日期
- 配置ConnectivityUSART2Mode配置为Asynchronous
- 可选在Project ManagerCode Generator里勾选Generate peripheral initialization as a pair of '.c/.h' files per peripheral这样会给每个外设的初始化函数生成单独.c/.h文件会使main.c更简洁
- 可选在clock configuration里把低速时钟源选为LSE
- 可选如果想掉保持时钟需要在RTC_Init函数中屏蔽掉设置时间的代码这样每次上电时就不会重新设置时间了就可以做到时间保持
- 注意HAL_RTC_GetTime得到的是BCD码的格式需要/16*10+%16转换成10进制数字