当前位置:网站首页>华大110时钟校准
华大110时钟校准
2022-07-16 20:30:00 【纸带】
//代码分析
//首先进行了系统时钟的一个初始化
//1初始化内容
//设置初始TRIM值,本样例采用从小到大的方式来TRIM,故此处设置为'1',后续不断更新该值后进行TRIM,直到符合条件(校准)为止
M0P_SYSCTRL->RCL_CR_f.TRIM = 1;
///< 使能待校准时钟,本样例对RCL 32768Hz进行校准
Sysctrl_ClkSourceEnable(SysctrlClkRCL, TRUE);//
///< 使能被监测时钟,本样例使用XTL
///< XTL 配置及使能
Sysctrl_XTLDriverCfg(SysctrlXtlAmp3, SysctrlXtalDriver3);
Sysctrl_SetXTLStableTime(SysctrlXtlStableCycle16384);
Sysctrl_ClkSourceEnable(SysctrlClkXTL, TRUE);
//初始化要点:1.设置了RCL_CR.TRIM的值为1。
//2打开RCL 32768
//3.TRIM的初始化
//打开TRIM外设时钟
Sysctrl_SetPeripheralGate(SysctrlPeripheralTrim, TRUE);//打开外设时钟? ///< 时钟校准
//TRIM校准流程
stcCfg.enMON = TrimMonDisable; //
stcCfg.enREFCLK = TrimRefMskXTL;
stcCfg.enCALCLK = TrimCalMskRCL;
stcCfg.u32RefCon = 328u; //10ms校准时间(增加该时间可提高TRIM精度)//根据参考时钟来的
stcCfg.u32CalCon = 0xFFFFFFFFu; //配置为默认值//这个可以先不用管。
Trim_Init(&stcCfg);
///< 打开TRIM中断使能//打开中断
Trim_EnableIrq();
///< 使能并配置TRIM 系统中断
EnableNvic(CLKTRIM_IRQn, IrqLevel3, TRUE);//中断中断号。
//4. Trim_Run();跑这个程序。
//主要是进入中断之后做什么事情。
volatile uint32_t u32CalCnt;
if(Trim_GetIntFlag(TrimStop))
{
u32CalCnt = Trim_CalCntGet();//获取的时间。
///<参考计数值计数完成(10ms)时,查看待校准计数值是否也为(10ms)计数值,或是否在允许误差范围内,此处为32768/100 = 328(±0.3%)
///<可根据实际修改该比较范围,提高TRIM校准精度。
if ((u32CalCnt <= (328u + 1u)) &&
(u32CalCnt >= (328u - 1u)))
{
Trim_Stop();
///< 校准结束,此时的TRIM值即为最佳频率值
u8TrimTestFlag = 0xFFu;
}
else
{
Trim_Stop();
///< 为达到目标精度,TRIM值增加1,继续校准
M0P_SYSCTRL->RCL_CR_f.TRIM += 1;
Trim_Run();
}
}
if(Trim_GetIntFlag(TrimCalCntOf)) //参考校准时间设置过长,导致待校准计数器溢出,此时需要重新配置参考校准时间及校准精度
{
u8TrimTestFlag = 0;
}边栏推荐
- 数据库常遇到的问题
- What did the new operator do? Interview
- Visual Studio 生产环境配置方案:SlowCheetah
- The mobile terminal is set with fonts smaller than 12px and script labels
- 2-conan 二進制包依賴管理方案
- [AI Engineering] 02-ai Engineering
- Web crawler technology creates its own Youdao dictionary
- Activity review | in depth chat with mindspire: how open source explores the whole scene of AI field
- Remember once, ants were abused on all sides. The water was too deep. Have you built the ferry across the river?
- [play with es] es batch / full import data
猜你喜欢

How to take long screenshots in win11? Win11 long screenshot method

Sff1602-mhchxm ultrafast recovery diode sff1602

Quickly solve the problem of error or garbled code when inserting Chinese data into mysql

Modify server password

时序事件数据怎么处理?【慕尼黑工业大学博士论文】神经时序点过程(NTPP): 连续时间事件数据建模

In addition to Chang'an, these four domestic brands also use "Lexus face". Has Chinese design regressed?

【部署】Redis

除了长安,这四个国产品牌也用“雷克萨斯脸”,中国设计倒退了?

alicloud3搭建wordpress

创建型模式之享元模式
随机推荐
Developers share | handwriting operator is not so difficult. I'll teach you to use mindspire to realize adaptive average pooling operator!
1. Create prism project
[play with es] es batch / full import data
技术干货 | 模型优化精度、速度我全都要!MindSpore模型精度调优实战(二)
封装、获取系统用户信息、角色及权限控制
记一次蚂蚁金服四面遭虐,面试水太深,过河的渡船你造好了吗?
LCD 显示撕裂解决
The distant savior obeys the objective law (V) -- cultural attribute
【AI工程】02-AI工程(AI Engineering)面面观
DeepMind最新114页报告《多智能体强化学习中的新兴易货贸易行为》
Uniapp Basics
时序事件数据怎么处理?【慕尼黑工业大学博士论文】神经时序点过程(NTPP): 连续时间事件数据建模
The distant savior obeys the objective law (VI) -- cultural attribute
[UCOS III source code analysis] - mutually exclusive semaphores (mutually exclusive locks)
(manual) [sqli-labs58-61] limit the injection times: error injection, get injection, character / number type
远程购买商品Solidity合约
哪个证券公司开户股票手续费低,哪个股票开户安全
(板子)AcWing841. 字符串哈希
Kaggle file download (weights, inference files...)
Voice conversion mainly involves technical records