3824 views|3 replies

1452

Posts

1

Resources
The OP
 

[GigaDevice GD32F310 Review] +RTC Usage [Copy link]

This post was last edited by jinglixixi on 2022-5-23 23:31

In the routine program of the development board, an RTC test program is provided, which displays the output content through the serial port, and can use the serial port to set the RTC initial test value and alarm prompt parameters. The test effect is shown in Figure 1.

Figure 1 Test results

After the program is modified, the timing function can be realized, and the effect is shown in Figure 2.

Figure 2 RTC timing

The modified display function is:

void rtc_show_time(void)
{
 rtc_current_time_get(&rtc_initpara);
 time_subsecond = rtc_subsecond_get();
printf("Current time: %0.2x:%0.2x:%0.2x \r\n", \
 rtc_initpara.rtc_hour, rtc_initpara.rtc_minute, rtc_initpara.rtc_second);
}

The corresponding main program is:

int main(void)
{
 systick_config();
 usart0_gpio_config();
 usart0_config();
 printf("\n\r ****************** RTC calendar alarm demo ******************\n\r");
 rcu_periph_clock_enable(RCU_PMU);
 pmu_backup_write_enable();
 rtc_pre_config();
 if(BKP_VALUE != RTC_BKP0) {
 rtc_setup();
 } else {
 if(RESET != rcu_flag_get(RCU_FLAG_PORRST)) {
 printf("power on reset occurred....\n\r");
 } else if(RESET != rcu_flag_get(RCU_FLAG_EPRST)) {
 printf("external reset occurred....\n\r");
 }
 printf("no need to configure RTC....\n\r");
 rtc_flag_clear(RTC_STAT_ALRM0F);
 exti_flag_clear(EXTI_17);
 rtc_show_time();
 rtc_show_alarm();
 }
 while(1){
 rtc_show_time();
 delay_1ms(1000);
 }
}

When adding an OLED screen display driver, the display effect shown in Figure 3 can be achieved by simply modifying the display program.

The corresponding display function is:

void rtc_show_time(void)
{
 rtc_current_time_get(&rtc_initpara);
 time_subsecond = rtc_subsecond_get();
OLED_ShowNum(20,4,rtc_initpara.rtc_hour/16*10+rtc_initpara.rtc_hour%16,2,16);
OLED_ShowNum(44,4,rtc_initpara.rtc_minute/16*10+rtc_initpara.rtc_minute%16,2,16);
OLED_ShowNum(68,4,rtc_initpara.rtc_second/16*10+rtc_initpara.rtc_second%16,2,16);
}

Figure 3 RTC electronic clock

Combined with the RTC parameter settings introduced above, a complete RTC electronic clock can be constructed.

This post is from GD32 MCU

Latest reply

Thanks for sharing, looking forward to the follow-up   Details Published on 2022-5-25 20:10
 

6818

Posts

11

Resources
2
 
RTC clock is very practical. Thanks for sharing. You are a professional evaluation expert.
This post is from GD32 MCU

Comments

How dare I, how dare I!  Details Published on 2022-5-25 09:15
 
 
 

1452

Posts

1

Resources
3
 
lugl4313820 posted on 2022-5-24 06:20 RTC clock, very practical, thank you for sharing, professional evaluation expert.

How dare I, how dare I!

This post is from GD32 MCU
 
 
 

7422

Posts

2

Resources
4
 

Thanks for sharing, looking forward to the follow-up

This post is from GD32 MCU
 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
Studying Things to Gain Knowledge 05: Dimensions and Elementary Functions

What is dimension? It is usually taught in middle school physics courses and again in university physics courses. Howev ...

【McQueen Trial】Comparison of the accuracy of several ultrasonic sensor programs of McQueen

Purpose Compare the test accuracy of several ultrasonic sensors to provide a reference for everyone's use. Methods Write ...

[Project source code] Digital tube companion - binary to BCD

This article and design code were written by FPGA enthusiast Xiao Meige. Without the author's permission, this article ...

Design of real-time image test device based on LVDS technology

Design of real-time image test device based on LVDS technology

C language uses binary tree to parse polynomials and evaluate

It mainly realizes the analysis of polynomial data calculation. If there is a need to make a simple calculator based on ...

LPS27HHTW MEMS Pressure Sensor

The LPS27HHTW MEMS pressure sensor is an ultra-compact piezoresistive absolute pressure sensor that can be used as a dig ...

Raspberry Pi Bluetooth Basics - Use of bluezero library

This post was last edited by lb8820265 on 2021-8-8 22:50 There are many libraries for operating Bluetooth in Linux s ...

CC2500 Migration Instructions

Be applicable : Applicable to TI chip CC2500 full series modules How to transplant ? The parts to be ported are in rf_ ...

Embedded Qt-Make a stopwatch

This post was last edited by DDZZ669 on 2022-8-7 15:55 Previous article: Embedded Qt - Write and run your first ARM-Qt ...

Successfully deployed deep learning gait recognition algorithm on Allwinner V853 platform

Xin Zhe, a student from the Communication Research Group of Beijing Institute of Technology, successfully transplanted t ...

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list