当前位置:网站首页>【S32K3_STM&PIT_MCAL】
【S32K3_STM&PIT_MCAL】
2022-04-22 04:29:00 【Neo_HeFeiyang】
这里写目录标题
1.Abbreviation
STM system timer Module
PIT periodic interrupt timer
2.PTI简介
PIT时钟源为AIPS_SLOW_CLK,其中RTI时钟为SIRC_CLK,用于在standby模式下唤醒CPU。
PIT共有3个instance,每个instance又有4个channel。其中PIT_0可以被链接成为一个64bit的定时器(正常为32bit的定时器)
PIT定时器为向下计数器,counter值写在LDVAL registers中。

3.STM简介
STM时钟来源于AIPS_PLAT_CLK or FXOSC or FIRC,可以在CGM中选择
3个stm instance,每个instance有4个32bit的compare channel,每个channel都有独立的中断。
1个32-bit的向上计数器,具有自己独立的8位预分频器,可进行0–256级分频。

4.EB配置
4.1.模块依赖关系:

主要为GPT模块,其对Mcl有依赖(主要是emios的依赖,若只使用STM和PIT只需加入此模块而无需配置此模块)。Platform用来配置定时器相关的中断,Mcu主要用来配置定时器的时钟频率。Port和Dio用来点灯方便观察实验现象。
4.2.Mcu配置
Mcu中主要是打开相关timer的外设时钟以及各时钟频率的时钟源选择和分频系数配置。
4.2.1.开外设时钟
打开用到的相关外设时钟:PIT0和STM0

4.2.2.配置时钟源及分频系数
4.2.2.1.STM0时钟配置
根据手册,可以看到STM0的时钟源有:AIPS_PLAT_CLK、FX0SC_CLK、FIRC_CLK.

此处,我们选择AIPS_PLAT_CLK作为STM0的时钟源,如图所示:

1.根据上一级时钟分频可以看到AIPS_PLAT_CLK的时钟为80MHz,1处的分频系数1需要+1作为最终的分频系数,即填1表示分频系数为2,填0表示分频系数为1.因此可以看到2处的最终时钟为40MHz

4.2.2.2.PIT0时钟配置
根据手册,可以看到除RTI外,PIT0的唯一时钟来源为AIPS_SLOW_CLK

我们将分频系数配置为3,实际为4,分频后频率为40MHz

当然更上一级的时钟如PLL_PHI0、PLL_PHI1、PLL_VCO等只在MCUPLL中配置,此处不做赘述。如下图所示:

4.3.Platform配置
使能pit0和stm0的中断

添加相应的中断处理函数

4.4.Gpt配置
4.4.1.打开定时器通道和中断

4.4.2.配置Gpt参考时钟

参考时钟来源:

4.4.3.GptPit配置

4.4.4.GptSTM配置

STM有自己独立的预分频器,这个预分频属于stm本身,跟上一级时钟无关。
上图中的两个stm预分频器,第一个是正常时候使用的,第二个是为双时钟模式准备的,一般不使用。配置为1即可。要使用需要打开如下的宏:

4.4.5.GptChannelConfiguration配置
添加前面配置的通道:

内部配置:以pit为例,stm同理

4.4.6.Generale配置
根据手册可知,RTC/SWT/PIT的RTI功能均可作为唤醒源使用

如果单纯的只使用定时器,则不需要打开下图中的功能:

若打开PredefTimerFunctionalityApi,则需要打开PREDEF timer,需要进行如下的时钟配置:

上述在选择GptHwChannel时需要在GptHwConfiguration中打开相应的通道:

也就是说PREDEF timer是一个与低功耗有关的定时器。
5.S32DS配置
添加相应的驱动模块:

Main函数中进行相关模块初始化,开启对应通达的定时器,使能相关回调函数。

根据EB的配置,编写相应的回调函数:

版权声明
本文为[Neo_HeFeiyang]所创,转载请带上原文链接,感谢
https://blog.csdn.net/HeFlyYoung/article/details/124290730
边栏推荐
- 【Taro开发】-全局自定义导航栏适配消息通知框位置及其他问题(十四)
- 软件测试的测试方法你知道多少?
- Introduction to Intel edge software center
- [concurrent programming 045] what is pseudo shared memory sequence conflict? How to avoid?
- Anaconda related
- How do I test the shuttle application? Unit test
- How does IOT platform realize business configuration center
- tensorflow报错:returned a result with an error set解决方案
- [force buckle] repeated substring
- WebSocket学习
猜你喜欢

How does IOT platform realize business configuration center

Filebeat collects log data and transfers it to redis. Different es indexes are created according to log fields through logstash

Statistics of authoritative institutions: the best data center network company in 2021, China Huawei and H3C, were listed
![[concurrent programming 043] how to solve the problems of CAS and ABA?](/img/bd/8638aa75d7d3b237d792a201e68c0f.png)
[concurrent programming 043] how to solve the problems of CAS and ABA?

02-SparkSQL

Sequence traversal of binary tree

05-Aggregation

01 knapsack problem (two-dimensional array solution and one bit array optimization)

Redis 的过期数据会被立马删除么?

Introduction to Intel edge software center
随机推荐
Revit (3) - 二开 -创建柱子
高斯分布——在误差测量中的推导
Experts have information | Zhang Zuyou: Tencent cloud devsecops practice and open source governance exploration
Zuo Chengyun - Dachang brushing class - the point with the most rope coverage
如何在 Bash 中将字符串计算为数字?
How to check whether the version of oraclejdk is charged on the official website
你的指针学到什么层次了?8个指针题目让你加深对指针的理解(下)-O-
[concurrent programming 044] CAS cycle time is too long. What's the problem?
L3-022 地铁一日游 (30 分)【floyd+dfs】
L1-052 2018 we want to win (5 points)
Bi set - SSM campus second-hand book sales system + thesis
调用函数时,关于传参那些事~
权威机构统计:2021 年最佳数据中心网络公司,中国华为和H3C上榜
Verify simple sorting using logarithm
二叉树的层序遍历
06-Datetimes
Statistics of authoritative institutions: the best data center network company in 2021, China Huawei and H3C, were listed
Websocket learning
L1-049 ladder race seat allocation (20 points)
7-2 symbol pairing | PTA