当前位置:网站首页>5. TPM module initialization
5. TPM module initialization
2022-07-01 01:06:00 【cyf31】
1、 In the manual TPM Definition of modules :
The TPM (Timer/PWM Module) is a two to eight channel timer which supports inputcapture, output compare, and the generation of PWM signals to control electric motor andpower management applications. The counter, compare and capture registers are clockedby an asynchronous clock that can remain enabled in low power modes.
That's the timer / Pulse width modulator module .
2、TPM The initialization of the module is mainly to configure various parameters of the timer
void TPM0_Init(void)
{
step1:
// Counter Reload On TriggerWhen set, the LPTPM counter will reload with zero
// (and initialize PWM outputs to their default value) whena rising edge is detected on the selected trigger input.
// 1 Counter is reloaded when a rising edge is detected on the selected input trigger
TPM0_CONF = TPM_CONF_CROT_MASK;
// Counter value
step2:
TPM0_CNT = 0;
step3:
TPM0_MOD = 0x2BC0;
step4:
TPM0_SC = TPM_SC_CMOD(1);
step5:
// Channel (n) Status and Control
TPM0_C4SC = TPM_CnSC_ELSB_MASK+TPM_CnSC_MSB_MASK;
step6:
TPM0_C4V = 0xFFF;
}
step1:TPM0_CONF register CROT The fields manual describes :

TPM0_CONF = TPM_CONF_CROT_MASK;
take CROT The field is configured as 1, That is, when the trigger detects the rising edge , Counter reloads .
step2: TPM0_CNT Zero clearing

TPM0_CNT = 0;
take TPM0_CNT Zero clearing .
step3:TPM0_MOD To configure
TPM0_MOD = 0x2BC0;
0x2BC0 Decimal system 11200, So when LPTPM The counter reaches 11200 When increasing , The overflow flag will be set (TOF), That is, the counter is accumulated to 11200 Mold taking operation .

step4: TPM0_SC register
TPM Status and control registers .
TPM0_SC = TPM_SC_CMOD(1);
Setting the CMOD by 1, The counter is in each LPTPM The counter clock is incremented .

step5:TPM0_C4SC
Configure two selection modes . configure Output compare Pattern . And step6 Used with the register of .
TPM0_C4SC = TPM_CnSC_ELSB_MASK+TPM_CnSC_MSB_MASK;


step6: TPM0_C4V To configure
TPM0_C4V = 0xFFF;
Put the register 8 individual bit Fully configured 1.
step5 Has been configured as output compare Pattern , So in the comparison mode , write in CnV The register will lock the value into the buffer . according to CnV Register update ,CnV The register is updated with the value it writes to the buffer .

边栏推荐
- $watch will not trigger data change - $watch not firing on data change
- 写给 5000 粉丝的一封信!
- Cmu15445 (fall 2019) project 1 - buffer pool details
- 2022-2028 global PTFE lined valve industry research and trend analysis report
- Tibetan poem PTA
- Ybtoj exchange game [tree chain splitting, line segment tree merging]
- [DaVinci developer topic] -37- detail IRV: introduction to inter runnable variable + configuration
- 解决 error MSB8031: Building an MFC project for a non-Unicode character set is deprecated.
- Luogu p1144 shortest circuit count
- 什么是产品思维
猜你喜欢

NE555波形发生器手把手教程之NE555内部结构(一)

Can JDBC based on openjdk connect to MySQL?

20220216 misc buuctf another world WinHex, ASCII conversion flag zip file extraction and repair if you give me three days of brightness zip to rar, Morse code waveform conversion mysterious tornado br
![[daily record] - bug encountered in BigDecimal division operation](/img/82/3105586841076b9bb1c57eac221ddf.png)
[daily record] - bug encountered in BigDecimal division operation

20220215 misc buctf easycap Wireshark tracks TCP flow hidden key (use of WinHex tool)

给按钮的边框和文字设置不同的背景色

剑指 Offer 18. 删除链表的节点

2022-2028 global retro glass industry research and trend analysis report

2022-2028 global encrypted external hard disk industry research and trend analysis report

Shift operators
随机推荐
Integer to hexadecimal string PTA
Member management applet actual development 07 page Jump
获取屏幕高度
Ybtoj exchange game [tree chain splitting, line segment tree merging]
MySQL variables, stored procedures and functions
CTF tool (1) -- archpr -- including installation / use process
NE555 waveform generator handle tutorial NE555 internal structure (I)
Authentication principle of Ranger plug-in
Implementation of date class
Sword finger offer 19 Regular Expression Matching
P4学习——Basic Tunneling
IBL预计算的疑问终于解开了
What should I do without 50W bride price
[untitled]
Cmu15445 (fall 2019) project 1 - buffer pool details
Using C language to realize the exchange between the contents of two arrays (provided that the array is the same size)
1009 product of polynomials (25 points) [PTA class A]
Experiment 8 T-SQL, stored procedure
The principle of journal node
A single element in an ordered array