Source file location STM32F10x_StdPeriph_Lib_V3.1.2\Project\STM32F10x_StdPeriph_Examples\RTC\Calendar
仔细阅读其中的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 Libraries\CMSIS\Core\CM3)
- stm32_eval.c (under Utilities\STM32_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.
According to previous experience,
it is recommended to select use microLIB in the project options.
Now it's time to go to bed.
Program address
RTC test successful
Reposted from Tony Embedded Forum, address: http://www.cevx.com/bbs/thread-26329-1-1.html
=========================================================
Key code analysis
/**
* @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("\r\n==============Time Settings=====================================");
printf("\r\n Please Set Hours");
while (Tmp_HH == 0xFF)
{
Tmp_HH = USART_Scanf(23); //If the data input into the HyperTerminal is greater than 23, the HyperTerminal will prompt an error
}
printf(": %d", Tmp_HH);
printf("\r\n Please Set Minutes");
while (Tmp_MM == 0xFF)
{
Tmp_MM = USART_Scanf(59);
}
printf(": %d", Tmp_MM);
printf("\r\n 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.2d\r", THH, TMM, TSS); //\rEnter, the cursor moves to the beginning of this line
}
Previous article:STM32 perpetual calendar displays year, month, day, hour, minute, second, week
Next article:stm32 CAN LoopBack self-test mode successful
Recommended ReadingLatest update time:2024-11-15 16:55
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- For NPN tubes, the c and e poles of U(br)ceo are both N-type, so where does the reverse statement come from?
- AWR1642: Add I2C driver support to the existing mmWave SDK demo
- 【GD32E503 Review】+ Littlefs Porting
- Solution to TL570x-EVM-A2 development board device node operation not permitted
- National Technology N32 MCU RF Resource Library (official, practical information)
- Raspberry Pi Pico Windows Development Environment - Compile under Visual Studio Code...
- Power circuit problem
- View Circuit-ADC and System (1)
- Teach you to understand the role of resistors in circuits
- EEWORLD University Hall----High-efficiency power architecture for smart door locks, battery-free light switches and wireless sensors