当前位置:文档之家› 飞思卡尔 HCS12 微控制器 ECT PWM 中文版

飞思卡尔 HCS12 微控制器 ECT PWM 中文版


定时器,预分频,计数器
寄存器:
1. TCNT
RST: 0.................................................................................................................. ......0 B7......................................................................B0
ECT 模块结构
• 一个16位向上带可编程
预分频的主计数器.
• 一个16位的带可编程预
分频的模数向下计数器 每个通道具备输入捕捉 和输出比较功能 可设置成2个16位脉冲 累加器. 实现不同的功能
• 8个独立的定时器通道,
• 4个8位脉冲累加器,也
• 通过对寄存器编程可以
Slide 2
TM
Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor , Inc. 2005.
Freescale
HCS12 微控制器 MC9S12DP256
2005年 8月
TM
Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc. 2005.
16 位自由运行/模计数器
B15.......................................................................................................................... ..…B0 Address Offset $0004, $0005
输出比较功能
• 在特定的时刻输出一个信号
TCNT
16位自由运行计数器
当比较寄存器的值和计数 器的值相等时,采取行动 比如:当TCNT=0x5678
相等
置位
清零
OR Pin
OCx
翻转
OR
比较
比较器
引脚控制逻辑
TOCx
16位输出比较寄存器 比如:0x5678 软件可以修改
OCxF 状态标志位置位,
当比较发生时(值相等时)
中断屏蔽 (通过软件使能)
OCxI
中断请求
• 共有8个输出比较通道 • 每个通道有自己的向量表和控制寄存器
Slide 6
TM
Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor , Inc. 2005.
1 – 定时器溢出中断使能 0 – 定时器中断禁止 TCRE - 允许使用PWM功能
Slide 4
TM
0 0 0 0 1 1 1 1
Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor , Inc. 2005.
输出比较 , OC7-OC0 中断: •清除中断,对TFLG1 其中的OCxF写’1’ •不要使用位操作 • •使用OC7-OC0向量表 复位条件: • 自由运行计数器(TCNT)被初始化为$0000,并且被禁止 • 输出比较寄存器被初始化为$0000 •捕捉/比较引脚与比较功能断开 •中断被禁止 •标志位被清零 •强制比较位被清零
.
TEN
TCNT
Address Offset $0004, 05
B0.......……...B7 B8……..........B15
PIN
DATA BUS
脉冲累加器
TSCR1 -定时器控制寄存器
TEN TSWAI TSFRZ TFFCA
R
0
R
0
R
0
R
0
$0006
RST:
0
0
0
0
R = Reserved
B7
3. TIE
B6 C6F
0
B5 C5F
0
B4 C4F
0
B3 C3F
0
B2 C2F
0
B1 C1F
0
B0 C0F
0
C7F
RST: 0
$000C
B7
4. TCTL1
RST:
B6 OL7
0
B5 OM6
0
B4 OL6
0
B3 OM5
0
B2 OL5
0
B1 OM4
0
B0 OL4
0
OM7
0
$0008
5. TCTL2
RST: 0
B7 OM3
0
B6 OL3
0
B5 OM2
0
B4 OL2
0
B3 OM1
0
B2 OL1
0
B1 OM0
0
B0 OL0
$0009
B7 6. CFORC
RST:
B6
B5
B4
B3
B2
B1
FOC1
0
B0 $0001
FOC7 FOC6 FOC5 FOC4 FOC3 FOC2 FOC0 0 0 0 0 0 0
3. TSCR2
RST:
TOI
0
0
0
0
0
0 TCRE PR2 PR1 PR0
0 0 0 0 0
$000D
预分频系数选择
PR2 PR1
0 0 1 1 0 0 1 1
PR0
0 1 0 1 0 1 0 1
除以
1 2 4 8 16 32 64 128
1 – 定时器由OC7比较符合时复位 0 – 定时器自由运行
定时器结构
模块时钟
M Clock
预分频选择
PR[2:0]
计时器溢出时,对溢出标志位 置位,如允许中断,则向CPU 发出中断请求
$FFFE $FFFF $0000
******* ****** ** ****
TOF
1
2
4 8 16 32 64 128
计数器寄存器
TCNT CLK
15...........................................0
2. TFLG1
C7F
0ቤተ መጻሕፍቲ ባይዱ
$000E
RST:
比较/捕捉标志位 写 ‘1’清除中断状态标志位
比较/捕捉屏蔽位 0 = 屏蔽中断请求 1 = 中断请求允许
输出模式和输出电平 (O7–OC0)
OMX 0 0 1 1 OLX 0 1 0 1 Action on OCx No Action OCx Toggle OCx Drive OCx LO Drive OCx HI
Slide 8
TM
Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor , Inc. 2005.
Slide 7
TM
0
Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor , Inc. 2005.
相关主题