1416 views|5 replies

1452

Posts

1

Resources
The OP
 

[Shanghai Hangxin ACM32F070 development board + touch function evaluation board evaluation] + RTC electronic clock [Copy link]

 This post was last edited by jinglixixi on 2022-10-19 09:55

ACM32F070 is equipped with an RTC timer. If a segment LCD screen is used to display the time, the time content will be incomplete. Therefore, the OLED screen introduced above can be used to complete the display work. The display effect is shown in Figure 1 and Figure 2.

Figure 1 Display effect

Figure 2 Display effect

The function to set and display the RTC time is:

void RTC_Test(void)
{
 uint32_t fu32_Seconds;
 RTC_ConfigTypeDef RTC_Handle;
 RTC_TimeTypeDef gstr_Time_Set;
 RTC_TimeTypeDef gstr_Time_Get;
 RTC_TimeTypeDef gstr_Time_Get_Again;
 RTC_DateTypeDef gstr_Date_Set;
 RTC_DateTypeDef gstr_Date_Get;
 RTC_Handle.u32_ClockSource = RTC_CLOCK_XTL;
 RTC_Handle.u32_Compensation = COMPENSATION_INCREASE;
 RTC_Handle.u32_CompensationValue = 0x05;
 HAL_RTC_Config(&RTC_Handle);
 gstr_Time_Set.u8_Hours = 0x12;
 gstr_Time_Set.u8_Minutes = 0x30;
 gstr_Time_Set.u8_Seconds = 0x00;
 HAL_RTC_SetTime(&gstr_Time_Set);
 gstr_Date_Set.u8_Year = 0x22;
 gstr_Date_Set.u8_Month = RTC_MONTH_ OCTOBER;
 gstr_Date_Set.u8_Date = 0x10;
 gstr_Date_Set.u8_WeekDay = RTC_WEEKDAY_ MONDAY;
 HAL_RTC_SetDate(&gstr_Date_Set);
 while (1)
 {
 HAL_RTC_GetTime(&gstr_Time_Get);
 HAL_RTC_GetDate(&gstr_Date_Get);
 HAL_RTC_GetTime(&gstr_Time_Get_Again);
 if (gstr_Time_Get.u8_Seconds != gstr_Time_Get_Again.u8_Seconds)
 {
 continue;
 }
 if (fu32_Seconds != gstr_Time_Get.u8_Seconds)
 {
 fu32_Seconds = gstr_Time_Get.u8_Seconds;
          OLED_ShowNum(0,5,gstr_Time_Get.u8_Hours,2,16);                 
                    OLED_ShowNum(24,5,gstr_Time_Get.u8_Minutes,2,16);
          OLED_ShowNum(48,5,gstr_Time_Get.u8_Seconds,2,16);
 }
 }
}

Since the read RTC time value is output in hexadecimal, a corresponding value implementation function needs to be configured, the content of which is as follows:

void OLED_ShowNum(uint8_t x,uint8_t y,uint32_t num,uint8_t len,uint8_t size2)
{
 uint8_t t,temp;
 uint8_t enshow=0;
 for(t=0;t<len;t++)
 {
 temp=(num/oled_pow(16,len-t-1))%16;
 if(enshow==0&&t<(len-1))
 {
 if(temp==0)
 {
 OLED_ShowChar(x+(size2/2)*t,y,' ',size2);
 continue;
 }
 else enshow=1;
 }
 OLED_ShowChar(x+(size2/2)*t,y,temp+'0',size2);
 }
}

On this basis, the main program to achieve the graphic effect is:

int main(void)
{
 System_Init();
 GPIO_Test();
app_OLED_Init();
 OLED_Init();
 OLED_Clear();
 OLED_ShowString(0,0,"ACM32F070",16);
 OLED_ShowString(0,2,"OLED & RTC",16);
OLED_ShowString(0,5," : :",16);
RTC_Test();
 while (1);
}

This post is from Domestic Chip Exchange

Latest reply

A must!   Details Published on 2022-10-20 11:59
 
 

7422

Posts

2

Resources
2
 

Thanks for sharing! Looking forward to the follow-up!

This post is from Domestic Chip Exchange

Comments

Thanks for your support!!!  Details Published on 2022-10-19 15:42
Personal signature

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

 
 
 

1452

Posts

1

Resources
3
 
freebsder posted on 2022-10-19 15:13 Thank you for sharing! Looking forward to the follow-up!

Thanks for your support!!!

This post is from Domestic Chip Exchange
 
 
 

6818

Posts

11

Resources
4
 

Every post of the teacher is a must-read, neat and typical teaching post!

This post is from Domestic Chip Exchange

Comments

Thanks for your support!!!  Details Published on 2022-10-20 09:10
 
 
 

1452

Posts

1

Resources
5
 
lugl4313820 posted on 2022-10-20 07:08 Every post of the teacher must be read, neat, typical teaching post!

Thanks for your support!!!

This post is from Domestic Chip Exchange

Comments

A must!  Details Published on 2022-10-20 11:59
 
 
 

6818

Posts

11

Resources
6
 
jinglixixi posted on 2022-10-20 09:10 Thank you for your support! ! !

A must!

This post is from Domestic Chip Exchange
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

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