HCS12ECTPWM增强型捕捉定时器模块_第1页
HCS12ECTPWM增强型捕捉定时器模块_第2页
HCS12ECTPWM增强型捕捉定时器模块_第3页
HCS12ECTPWM增强型捕捉定时器模块_第4页
HCS12ECTPWM增强型捕捉定时器模块_第5页
已阅读5页,还剩41页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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.TMFreescale HCS12 微控制器微控制器MC9S12DP2562

2、005年年8月月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.TMEnhanced Capture Timer Modul

3、e增强型捕捉定时器模块增强型捕捉定时器模块TMFreescale 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 2ECT 模块结构

4、模块结构一个16位向上带可编程预分频的主计数器.一个16位的带可编程预分频的模数向下计数器8个独立的定时器通道,每个通道具备输入捕捉和输出比较功能4个8位脉冲累加器,也可设置成2个16位脉冲累加器.通过对寄存器编程可以实现不同的功能TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names

5、are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 3定时器结构定时器结构预分频选择 PR2:0M Clock1 2 4 8 16 32 64 128TCNT15.0DATA BUSPINRRRR1 计数器使能0 计数器禁止TEN TSWAI TSFRZ TFFCATSCR1 -定时器控制寄存器定时器控制寄存器RST: 0 0 0 0 0 0 0 0TCNT CLK.TENB0.B7 B8.B15R = Reserved$0006Address Offset $0004, 0

6、5$FFFE$FFFF$0000*TOF模块时钟模块时钟计数器寄存器计数器寄存器脉冲累加器脉冲累加器计时器溢出时,对溢出标志位置位,如允许中断,则向CPU发出中断请求TMFreescale 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 respect

7、ive owners. Freescale Semiconductor, Inc. 2005.Slide 4定时器,预分频,计数器定时器,预分频,计数器寄存器:1. TCNT 16 位自由运行/模计数器B15.B0RST: 0.0 Address Offset $0004, $00051 定时器溢出中断使能0 定时器中断禁止$000D3. TSCR2 RST: 0 0 0 0 0 0 0 0 1 定时器由OC7比较符合时复位0 定时器自由运行TCRE - 允许使用PWM功能B7.B0TOI 0 0 0 TCRE PR2 PR1 PR02. TFLG2定时器溢出标志位,写 1 清零TOF 0 0

8、 0 0 0 0 0B7.B0RST: 0 0 0 0 0 0 0 0$000F标志寄存器标志寄存器除以1248163264128000011110101010100110011PR2 PR1 PR0 预分频系数选择预分频系数选择TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names a

9、re the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 5定时器编程步骤定时器编程步骤用途: 产生周期中断初始化设定预分频系数定时器溢出中断使能定时器使能中断函数清标志位1.用户自己的代码void ECT_Init(void) TSCR2_PR = 7; /prescale factor is 8, bus clock/128=8Mhz/8 TSCR2_TOI = 1; /timer overflow interrupt enable TSCR1_TEN = 1; /timer e

10、nable#pragma CODE_SEG NON_BANKED#pragma TRAP_PROCvoid Int_TimerOverFlow(void) TFLG2_TOF = 1; /clear timer overflow flag /用户自己的代码 .#pragma CODE_SEG DEFAULT在PRM文件中,加入VECTOR ADDRESS 0 xFFDE Int_TimerOverFlowTMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale

11、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 6输出比较功能输出比较功能16位自由运行计数器16位输出比较寄存器 比如:0 x5678 软件可以修改引脚控制逻辑中断请求OCxF状态标志位置位,当比较发生时(值相等时)OCxI中断屏蔽(通过软件使能) 共有8个输出比较通道 每个通道有自己的向量表和控

12、制寄存器 在特定的时刻输出一个信号在特定的时刻输出一个信号当比较寄存器的值和计数器的值相等时,采取行动比如:当TCNT=0 x5678TCNTTOCxPinOCx比较比较比较器相等相等置位置位OROR清零清零翻转翻转TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the

13、property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 7输出比较寄存器输出比较寄存器 C7F C6F C5F C4F C3F C2F C1F C0FOM7OL7OM6OL6OM5OL5OM4OL41. TC7 TC02. TFLG13. TIE4. TCTL1 比较/捕捉标志位写 1清除中断状态标志位 比较/捕捉屏蔽位 0 = 屏蔽中断请求 1 = 中断请求允许 OMXOLXAction on OCx00110101No Action OCxToggle OCxDrive OCx LODriv

14、e OCx HI输出模式和输出电平 (O7OC0)B6B5B4B3B7B2B1B05. TCTL2B6B5B4B3B7B2B1B0RST: 0 0 0 0 0 0 0 0$0008RST: 0 0 0 0 0 0 0 0RST: 0 0 0 0 0 0 0 0RST: 0 0 0 0 0 0 0 0$000C$000E$0009Address Offset$0010 - $0011 - -$001E - $001F16 位捕捉/比较寄存器 (TC7) 16 位捕捉/比较寄存器 (TC0) - C7F C6F C5F C4F C3F C2F C1F C0FB6B5B4B3B7B2B1B0OM3O

15、L3OM2OL2OM1OL1OM0OL0B6B5B4B3B7B2B1B0FOC7 FOC6 FOC5 FOC4 FOC3 FOC2 FOC1 FOC06. CFORCB7 B6 B5 B4 B3 B2 B1 B0RST: 0 0 0 0 0 0 0 0$0001TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or

16、 service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 8输出比较输出比较, OC7-OC0中断: 清除中断,对TFLG1 其中的OCxF写1不要使用位操作使用OC7-OC0向量表复位条件: 自由运行计数器(TCNT)被初始化为$0000,并且被禁止 输出比较寄存器被初始化为$0000捕捉/比较引脚与比较功能断开中断被禁止标志位被清零强制比较位被清零TMFreescale Semiconductor Confidential and Propriet

17、ary 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 9输出比较输出比较, 通道通道7 OC7 (1 of 2)用途: 1、多个输出比较引脚的控制2、通过2个输出比较来控制1个引脚,可以输出短脉冲在每个时钟周期内,输

18、出比较寄存器7和自由运行的计数器进行比较如果它们的值相等,则:1、中断标志位被置12、输出引脚OC7-OC0的状态被改变 或/和 产生中断OC7可以影响多个引脚(OC7-OC0)当OC7和OC7-OC0某个引脚的动作有冲突时,OC7的动作将被执行 TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or servic

19、e names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 10输出比较输出比较 7 (2 of 2) C7I C6F C5F C4F C3F C2F C1F C0F OC7M7 OC7M6 OC7M5 OC7M4 OC7M3 OC7M2 OC7M1 OC7M04. TIE 定时器中断允许使能5. OC7M - OC7MASKB7.B0 1 - TC7 -16 位比较寄存器7. RST: 0 0 0 0 0 0 0 0RST: 0 0 0 0 0 0 0 0$0002

20、$000C C7F C6F C5F C4F C3F C2F C1F C0FRST: 0 0 0 0 0 0 0 0$000EB7.B02. TCNT - 16-位计数器B15.B0RST: 0.0$0004, $05B7.B03. TFLG1 标志位 OC7D7 OC7D6 OC7D5 OC7D4 OC7D3 OC7D2 OC7D1 OC7D06. OC7D - OC7DATARST: 0 0 0 0 0 0 0 0$0003B7.B0OC7MASK 根据寄存器的设置,可以控制任意一路或全部输出比较引脚 OC7DATA 当OC7比较事件发生时,引脚的逻辑电平TMFreescale Semico

21、nductor 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 11定时器溢出时电平翻转定时器溢出时电平翻转TOV7 TOV6 TOV5 TOV4 TOV3 T

22、OV2 TOV1 TOV0 TOVx 定时器溢出时,电平翻转只有当通道被配置成输出比较时,才有效Address Offset $0007RST: 0.01. TTOV -定时器溢出时电平翻转寄存器$000D2. TSCR2 定时器系统控制寄存器 RST: 0 0 0 0 0 0 0 0 B7.B0TOI 0 0 0 TCRE PR2 PR1 PR01 定时器由 OC7 比较事件发生来复位0 定时器自由运行TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale

23、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 12输入捕捉输入捕捉, IC7-IC0 (1 of 3)用途用途:1、测量事件发生的间隔时间、测量事件发生的间隔时间2、对实时时间进行响应、对实时时间进行响应输入捕捉能感应到引脚上的电平的变化输入捕捉能感应到引脚上的电平的变化如果发现电平变化,则:如果

24、发现电平变化,则:1、计数器的值被保存到到输入捕捉寄存器中,状态、计数器的值被保存到到输入捕捉寄存器中,状态标志位被置标志位被置12、如果中断允许,则向、如果中断允许,则向CPU发出中断请求发出中断请求TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the propert

25、y of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 13输入捕捉功能输入捕捉功能比较/捕捉 单元16位自由运行计数器16位输入捕捉锁存器捕捉发生时,状态位置1向CPU发出中断请求Edge沿选择检测ICxICxFICxI上升/下降沿可选中断屏蔽当外部事件发生时,或外部信号输入发生变化时,记录当前时间TCNTTICx延时计数器 0 0 0 0 0 0 DLY1 DLY0Bit 7 6 5 4 3 2 1 0DLYCT 延时计数器控制寄存器DLY1:0 - Delay Counter Values 00 = D

26、isabled 01 = 256 M Clocks 10 = 512 M Clocks 11 = 1024 M ClocksAddress Offset $0029注: 如果输入信号电平和跳变之前的电平相反时,延时计数器在当前时钟计数时刻产生一个脉冲,它用来去除噪声OROR16位保持寄存器应用: ABS 刹车. 雷达测距,发动机引脚 共有8个输入捕捉通道 每个通道有自己的向量表和控制寄存器TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are

27、 trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 14输入捕捉输入捕捉, IC7-IC0 (2 of 3)B2B1B0EDGxB 输入捕捉沿控制(IC7IC0)EDGxAICx EDGE0101无边沿 ICx 禁止上升沿下降沿任何沿4. TCTL3 C7F C6F C5F C4F C3F C2F C1F C0FC7I

28、 C6I C5I C4I C3I C2I C1I C0I2. TFLG13. TMSK11. TC7 TC0EDG7B EDG7A EDG6B EDG6A EDG5B EDG5A EDG4B EDG4A5. TCTL4EDG3B EDG3A EDG2B EDG2A EDG1B EDG1A EDG0B EDG0AB6B5B4B3B7B2B1B0RST: 0 0 0 0 0 0 0 0RST: 0 0 0 0 0 0 0 0RST: 0 0 0 0 0 0 0 0RST: 0 0 0 0 0 0 0 0B6B5B4B3B7B2B1B0B6B5B4B3B7B2B1B0B6B5B4B3B7B2B1B0

29、$000E$000C$000A$000BAddress Offset$0010 - $0011 - -$001E - $001F16 位捕捉/比较寄存器 (TC7) 16 位捕捉比较寄存器 (TC0) - 比较/捕捉标志位写 1清除中断状态标志位 比较/捕捉屏蔽位 0 = 屏蔽中断请求 1 = 中断请求允许 0011TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconducto

30、r, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 15输入捕捉输入捕捉/输出比较选择输出比较选择IOS7 IOS6 IOS5 IOS4 IOS3 IOS2 IOS1 IOS0TIOS 定时器输入捕捉定时器输入捕捉/输出比较选择寄存器输出比较选择寄存器 IOSx = 1 输出比较功能 = 0 输入捕捉功能RST: 0 0 0 0 0 0 0 0$0000B6B5B4B3B7B2B1B0TIM

31、ER 定时器使能1 计数器使能0 计数器禁止TSCR 定时器系统控制寄存器RST: 00$0006TEN TSWAI TSFRZ TFFCA Reserved TSWAI 在WAIT模式时,定时器停止 0 = 不停止 1 = 停止TSBCK 在DEBUG模式时, 定时器停止 0 = 不停止 1 = 停止TFFCA 定时器快速标志位清除使能 0 = 定时器标志位正常清零 1 = 输入捕捉时读取寄存器, 输出比较时写寄存器,可以对相应通道标志位清零TMFreescale Semiconductor Confidential and Proprietary Information. Freescal

32、e 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 16脉冲累加模式脉冲累加模式8 位计数器PA7/PAI 脉冲累加器输入引脚 事件计数模式引脚作为计数器时钟软件选择以什么沿来计数计数器溢出时,产生中断(可选)在PAI引脚每个主动电平将产生中断 8 位计数器PA7

33、/PAI 脉冲累加器输入引脚 时间累加模式引脚作为计数器软件选择主动电平作为门的输入当计数器溢出时产生中断在使能的引脚上后面的边缘时产生中断 自由运行E/64时钟对事件计数模式,PEDGE 选择哪个PAI的沿用来增加 PACNT寄存器对门累加模式,PEDGE选择哪个PAI 状态用来禁止计数(比如. PEDGE = 1 - 禁止计数 当PAI = HI). TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Fr

34、eescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 17脉冲累加结构脉冲累加结构PINTCx PIN Logic DIV by 64Control Reg.+ 8/16 BIT CNTRHolding RegisterPOLARITYCONTROL PTxIRQDATABUS注 1: PTx 可以被用作脉冲累加,输入捕捉或输出比较这里 PTx = PT

35、0 - PT3SELECTED CLOCKDelayCounterEdgeDetector 0 0 0 0 0 0 DLY1 DLY0Bit 7 6 5 4 3 2 1 0DLYCT - Delay Counter Control RegisterDLY1:0 - Delay Counter Values 00 = Disabled 01 = 256 M Clocks 10 = 512 M Clocks 11 = 1024 M ClocksAddress Offset $0029注: 如果输入信号电平和跳变之前的电平相反时,延时计数器在当前时钟计数时刻产生一个脉冲,它用来去除噪声TMFrees

36、cale 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 18增强型捕捉增强型捕捉ECT比标准的比标准的TIM增强的特点增强的特点

37、4个输入捕捉通道有16位缓冲寄存器 4个8位 / 2个16位脉冲累加器 16位带4位预分频的模数向下计数器 4个用户选择的延时计数器用来消除噪声 主定时器预分频扩展至7位 队列和锁定模式 主定时器输入捕捉寄存器保持寄存器外部事件外部事件拷贝拷贝拷贝拷贝拷贝拷贝读取数据读取数据读取数据读取数据外部事件外部事件TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, In

38、c. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 19模向下计数器模向下计数器二进制向下计数器. 可以完全控制计数起始值 应用于精确事件计时-用于产生周期性的标志位和中断主定时器单独运行。时钟来自总线时钟,并经过预分频。可以被设置为定时中断或产生标志位。或装载初始值后向下计数到$0000。ParameterValueUnitsCrystal Frequency16MHzBus Frequency8M

39、HzBus Tick Time125.0000nSPeriodic Interrupt Time191uSBus Ticks Required1528.00TicksModulus Counter Prescaler4Modulus Counter Start Value382装载向下计数至0执行动作执行动作TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, I

40、nc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 20ABS 应用举例应用举例PT0PT1PT2SENSOR 1SENSOR 2SENSOR 3SENSOR 4PB1PB2PB3PB4BRAKEFLUIDPUMPSYSTEMSIGNALCONDITIONINGLOGIC IC/PASIGNALCONDITIONINGLOGICSIGNALCONDITIONINGLOGICSIGNALCONDITI

41、ONINGLOGICPT3左前轮左前轮 右前轮右前轮 左后轮左后轮右后轮右后轮HCS12TIMER 定时器输入捕捉测量车轮转速 发送命令到刹车压力调节阀来调节压力 IC/PA IC/PA IC/PA如果左右轮速脉冲周期不等则则调节电磁阀调节电磁阀TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service

42、 names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 21低功耗模式低功耗模式TSCR 定时器系统控制寄存器RST: 00$0006TEN TSWAI TSFRZ TFFCA Reserved TSWAI 在WAIT模式时,定时器停止 0 = 不停止 1 = 停止TSBCK 在DEBUG模式时, 定时器停止 0 = 不停止 1 = 停止TFFCA 定时器快速标志位清除使能 0 = 定时器标志位正常清零 1 = 输入捕捉时读取寄存器, 输出比较时写寄存器,可以对相应

43、通道标志位清零TMFreescale 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 22PULSE WIDTH MODULATIO

44、N(PWM)脉宽调制模块脉宽调制模块TMFreescale 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 23什么是什么是PWM?

45、periodonTTRatio Width PulseTonToffTperiodAverage0 %10 %50 %90 %99 %应用: D/A转换 马达控制 音调生成 正弦波生成占空比占空比=高电平时间高电平时间/周期周期 =Ton/TperiodTMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or ser

46、vice names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 24PWM信号的产生信号的产生(边缘对齐边缘对齐)开始周期 TPWMTPWM占空比 TDutyPWMDTYxPWMPERxPWMPERxfClock, TClock8-bit CounterPWMCNTx时钟8-bit Compare =PWMDTYx8-bit Compare =PWMPERx0 x000 x00ResetPin当当8位计数器的值等于位计数器的值等于PWMDTY(duty cycle寄

47、存器寄存器)时,电平从有效跳到无效;时,电平从有效跳到无效;当当8位计数器的值等于位计数器的值等于PWMPER(周期寄存器)时,电平从无效跳到有效,然(周期寄存器)时,电平从无效跳到有效,然后计数器清后计数器清0,重新开始计数,重新开始计数TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service na

48、mes are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 25PWM 模块特点模块特点 8个带周期占空比可程控的PWM独立通道 4个可程控选择的时钟源 每个PWM通道有专用的计数器 PWM每个通道脉冲极性可以选择 每个PWM通道可使能/禁止 周期和占空比双缓冲 每个通道有中心对齐和边缘对齐方式 分辨率: 8位 (8通道), 16位 (4通道) 带中断功能的紧急切断 工作模式TMFreescale Semiconductor Confidential and Propriet

49、ary 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 26PWM 结构框图结构框图通道通道 7周期和占空比计数器通道通道 6周期和占空比计数器.通道通道 0周期和占空比计数器管脚使能选择极性选择对齐方式选择管脚管脚T

50、MFreescale 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 27PWM 初始化步骤初始化步骤禁止PWM Disable P

51、WMPWME选择时钟 Select clock (prescaler and scale) for the PWM PWMPRCLK, PWMSCLA, PWMSCLB, PWMCLK选择极性 Select polarityPWMPOL选择对齐模式 Select center or left aligned modePWMCAE对占空比和周期编程Program duty cycle and periodPWMDTYx, PWMPERx使能PWM通道 Enable used PWM channelsPWMETMFreescale Semiconductor Confidential and Pr

52、oprietary 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 28PWM 时钟选择时钟选择 (1 of 4)Clock A (Ch 0, Ch 1, Ch 4, Ch 5)Clock SA (scaled A;

53、Ch 0, Ch 1, Ch 4, Ch 5)Clock B (Ch 2, Ch 3, Ch 6, Ch 7)Clock SB (scaled B; Ch 2, Ch 3, Ch 6, Ch 7)4个时钟源:Bus ClockDivide by Prescaler Taps:248163264128预分频PWMPRCLK $_03Clock SAClock SBClock AFurther Division of the clock:2468.512Clock BFurther Division of the clock:2468.512PWMSCLA $_08PWMSCLB $_09分频TM

54、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 29PWM 时钟选择时钟选择 预分频寄存器预分频寄存器 (2 o

55、f 4)0PCKB2 PCKB1 PCKB00PCKA2 PCKA1 PCKA0RWReset: 00000000= Unimplemented or ReservedPWMPRCLK $_03PCKx2PCKx1PCKx0Value of Clock x000Bus Clock001Bus Clock / 2010Bus Clock / 4011Bus Clock / 8100Bus Clock / 16101Bus Clock / 32110Bus Clock / 64111Bus Clock / 128可在任意时刻读写!x = A or B设置 PRESCALE 寄存器:PWMPRCLK

56、 = 0 x22;/ B= Bus/4, A = Bus/4PWMPRCLK = 0 x07;/ B = Bus, A = Bus/128Software ExamplesBit 0Bit 1Bit 2Bit 3Bit 4Bit 5Bit 6Bit 0TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or serv

57、ice names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 30PWM 时钟选择时钟选择 分频寄存器分频寄存器(3 of 4)总线时钟fBusDivide by Prescaler Taps:2481632641288-Bit Down CounterBit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0PWMSCLx分频值SxClockxClockPWMSCLxPWMSCLxxClockSxClock_2_2_PWMSCL

58、x = $00 PWMSCLx value is 256可在任意时刻读写!x = A or B/ 2Clock SxClock xClock x = fBus / PWMPRCLKCount = 1PWMPRCLK $_03PWMSCLB $_09PWMSCLA $_08例如:要求: Clock Sx = 1 kHz总线时钟 = 16 MHzPrescaler = 128 Prescaler = 64Clock x = 125 kHzClock x = 250 kHzPWMSCLx = 63 PWMSCLx = 125 Clock Sx = 992 HzClock Sx = 1000 HzTM

59、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 31PWM 时钟选择寄存器时钟选择寄存器 (4 of 4)PCL

60、K6 PCLK5 PCLK4 PCLK3 PCLK2 PCLK1 PCLK0RWReset: 00000000PWMCLK $_02PCLK7选择时钟源:PCLK0 = 1;/ SA is source of ch 0PCLK6 = 0;/ B is source of ch 6PWMCLK = 0 x11; / all channels软件示例软件示例Bit 0Bit 1Bit 2Bit 3Bit 4Bit 5Bit 6Bit 0PCLK5 通道 5时钟选择 1 =时钟源为SA 0 =时钟源为APCLK4 通道 4时钟选择 1 =时钟源为SA 0 =时钟源为APCLK3 通道 3时钟选择 1

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论