找回密码
 立即注册
查看: 4881|回复: 9

STC8H8K64U_TSSOP20内置RTC

[复制链接]
  • 打卡等级:以坛为家II
  • 打卡总天数:433
  • 最近打卡:2025-04-30 07:30:29
已绑定手机

229

主题

328

回帖

1467

积分

金牌会员

积分
1467
发表于 2023-3-17 10:34:30 | 显示全部楼层 |阅读模式
本帖最后由 STC32G12K128 于 2023-3-17 11:21 编辑

当未对RTC任何初始化操作,上电RTC就会发生一次闹钟中断(在没有打开闹钟中断的情况下)

当上电对RTC闹钟写入配值并打开闹钟中断时并不会发生闹钟中断(有初始化就正常,没有任何初始化就不正常)

回复

使用道具 举报 送花

  • 打卡等级:偶尔看看II
  • 打卡总天数:20
  • 最近打卡:2025-04-28 16:56:43

21

主题

376

回帖

2345

积分

超级版主

积分
2345
发表于 2023-3-17 11:14:23 | 显示全部楼层
本帖最后由 STC32G12K128 于 2023-3-17 11:41 编辑

RTC, 年月日时分秒,必须 外部 32768的 专用晶振,也才 RMB0.15
RTC 用外部 32768晶振; CPU 跑内部高速 HIRC时钟;
你外部挂了 32768 高精准 RTC 时钟,就可以用内部硬件根据外部时钟自动校准内部高速 HIRC时钟,如 45MHz
另外您可以看下手册的这个章节,看看是不是哪里设置的不对:
1679024363127.jpg




电话:0513-55012946 QQ:2195591714  微信:  19952583740
  • 打卡等级:偶尔看看III
  • 打卡总天数:54
  • 最近打卡:2025-05-01 09:07:55

717

主题

1万

回帖

1万

积分

管理员

积分
15607
发表于 2023-3-17 13:44:20 | 显示全部楼层
1.png

STC8H-20230316.pdf

21.42 MB, 下载次数: 130

  • 打卡等级:以坛为家II
  • 打卡总天数:415
  • 最近打卡:2025-04-30 09:58:34
已绑定手机

39

主题

2006

回帖

6841

积分

论坛元老

积分
6841
发表于 2023-3-17 13:45:19 | 显示全部楼层
我按照你的方法试了一下,没有遇到你说的那种现象。

附件是我的测试程序,你可以将RTC_config配置函数屏蔽掉,试试不对RTC任何初始化操作情况下,上电会不会产生闹钟中断。
测试例程在中断函数里面判断是闹钟中断的话,翻转一个带指示灯的IO口,并设置B_Alarm标志:
  1. if(RTCIF & 0x80)    //闹钟中断
  2.         {
  3.                 P11 = !P11;
  4.                 RTCIF &= ~0x80;
  5.                 B_Alarm = 1;
  6.         }
复制代码
主循环里判断B_Alarm被置位的话,通过CDC串口打印一串数据:
  1. if(B_Alarm)
  2.         {
  3.             B_Alarm = 0;
  4.             printf("RTC Alarm!\r\n");
  5.         }
复制代码
所以不管通过指示灯还是CDC串口都可以判断是否产生了闹钟中断。
如果还是觉得有问题的话,请提供可以复现问题的测试例程。



通过USB-CDC串口打印RTC时钟.zip

43.2 KB, 下载次数: 145

  • 打卡等级:初来乍到
  • 打卡总天数:4
  • 最近打卡:2025-05-01 06:58:22

5

主题

184

回帖

1331

积分

金牌会员

积分
1331
发表于 2023-5-15 14:35:12 | 显示全部楼层
STC32G12*** 发表于 2023-3-17 11:14
RTC, 年月日时分秒,必须 外部 32768的 专用晶振,也才 RMB0.15
RTC 用外部 32768晶振; CPU 跑内部高速 H ...

You say
you have a 32768 high-precision RTC clock externally, you can use the internal hardware according to the external The clock automatically calibrates the internal high-speed HIRC clock, such as 45MHz.


Is there any example, of how the 32768 is used to automatically calibrate the internal high-speed HIRC clock ?

What HIRC clock MHz choices can be calibrated ?
回复 支持 0 反对 1

使用道具 举报 送花

  • 打卡等级:偶尔看看II
  • 打卡总天数:20
  • 最近打卡:2025-04-28 16:56:43

21

主题

376

回帖

2345

积分

超级版主

积分
2345
发表于 2023-5-15 16:25:47 | 显示全部楼层
本帖最后由 STC32G12K128 于 2023-5-15 16:45 编辑

附件有测试范例,您可以测试看看:
使用STC出厂前用专业时钟调校设备,调校的如下10种常用高精准内部HIRC频率--STC8H8K64U
22.1184MHz,24MHz,27MHz,30MHz,33.1776MHz,35MHz,36.864MHz,40MHz,44.2368MHz,48MHz
在用户程序区用户自己选择设置如上STC出厂前调校的这10种内部高精准的HIRC的频率--STC8H8K64U
===常温下STC出厂前用专业的高精准设备调校的这10个固定频率时钟误差 < + - 0.3%
===没有压飘,只有+-1%附近的温漂【-40度 ~ +85度】
而如用户使用在ISP烧录时任意设置的频率,虽然范围很宽很灵活,但如用户使用第三方不专业的USB转串口来烧录,
来校准成其他的频率,这有可能会将第三方不专业工具的时钟误差,在用户ISP下载时重新校准频率而带入芯片内部
即使用户要设置特殊的频率,也请使用 STC的专业工具 STC-USB Link1D
===用STC-ISP下载时设置任意频率, 请使用STC-USB Link1D来校准内部高精准HIRC的频率,
===这个STC-USB Link1D 专业工具专门外挂了22.1184MHz晶振来ISP下载时校准内部时钟到任意频率
===STC-USB Link1D是【专业仿真器,专业在线全自动下载器/无需手工停电,专业脱机烧录器,专业时钟校准器】
这是超级重点,不要那么强大的内部时钟不会自己在程序区自己任意设置

1.png

通过USB-CDC串口打印RTC时钟.zip

43.2 KB, 下载次数: 90

电话:0513-55012946 QQ:2195591714  微信:  19952583740
回复 支持 0 反对 1

使用道具 举报 送花

  • 打卡等级:初来乍到
  • 打卡总天数:4
  • 最近打卡:2025-05-01 06:58:22

5

主题

184

回帖

1331

积分

金牌会员

积分
1331
发表于 2023-5-16 08:47:01 | 显示全部楼层
Thank you.
That reply refers to initial calibrate of the HIRC, using the stored values, or using Link1D, to calibrate to ±0.3%

You stated before
You have a 32768 high-precision RTC clock externally, you can use the internal hardware according to the external The clock automatically calibrates the internal high-speed HIRC clock, such as 45MHz.


Which suggests the precision RTC crystal can calibrate (somehow?) the HIRC, as other vendors can do ?  Or do I not understand what you wrote ?

Can you somehow auto calibrate the HIRC for run-time correction of the average MHz, to (much) better than the ±0.3% ?
or if it is not supporting Automatic calibrate, is there some way to capture a HIRC timer reading, using the RTC crystal signal ?
回复 支持 0 反对 1

使用道具 举报 送花

  • 打卡等级:偶尔看看II
  • 打卡总天数:20
  • 最近打卡:2025-04-28 16:56:43

21

主题

376

回帖

2345

积分

超级版主

积分
2345
发表于 2023-5-16 09:00:38 | 显示全部楼层
RTC, month, day, hour, minute, second, must have an external 32768 dedicated crystal oscillator。

电话:0513-55012946 QQ:2195591714  微信:  19952583740
回复 支持 0 反对 1

使用道具 举报 送花

  • 打卡等级:初来乍到
  • 打卡总天数:4
  • 最近打卡:2025-05-01 06:58:22

5

主题

184

回帖

1331

积分

金牌会员

积分
1331
发表于 2023-5-16 10:18:08 | 显示全部楼层
I am trying to understand your comment in #2
You have a 32768 high-precision RTC clock externally , you can use the internal hardware according to the external The clock automatically calibrates the internal high-speed HIRC clock , such as 45MHz.

To calibrate such as 45MHz against 32.768kHz crystal, as one example you would capture 45MHz divided by 1372=TC and sample TC 3 times
samples of 001 or 000 is HIRC is too slow, 011 is 'locked' and 111 is too fast.

I am unclear of the STC8H or any STC MCUs have that level of hardware calibrate support ?  
回复 支持 0 反对 1

使用道具 举报 送花

  • 打卡等级:偶尔看看II
  • 打卡总天数:20
  • 最近打卡:2025-04-28 16:56:43

21

主题

376

回帖

2345

积分

超级版主

积分
2345
发表于 2023-5-16 11:11:09 | 显示全部楼层
Before using STC factory, use professional clock calibration equipment to adjust the following 10 commonly used high-precision internal HIRC frequencies - STC8H8K64U

22.1184MHz,24MHz,27MHz,30MHz,33.1776MHz,35MHz,36.864MHz,40MHz,44.2368MHz,48MHz

In the user program area, the user chooses to set the frequency of these 10 kinds of internal high-precision HIRC, STC8H8K64U, which are calibrated before the STC leaves the factory
电话:0513-55012946 QQ:2195591714  微信:  19952583740
回复 支持 0 反对 1

使用道具 举报 送花

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|深圳国芯人工智能有限公司 ( 粤ICP备2022108929号-2 )

GMT+8, 2025-5-1 12:11 , Processed in 0.124350 second(s), 114 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表