Freescale S12 PWM模块

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

FreescaleSemiconductorConfidentialandProprietaryInformation.Freescale™andtheFreescalelogoaretrademarksofFreescaleSemiconductor,Inc.Allotherproductorservicenamesarethepropertyoftheirrespectiveowners.©FreescaleSemiconductor,Inc.2005.TMPulseWidthModulation(PWM)脉宽调制模块TMFreescaleSemiconductorConfidentialandProprietaryInformation.Freescale™andtheFreescalelogoaretrademarksofFreescaleSemiconductor,Inc.Allotherproductorservicenamesarethepropertyoftheirrespectiveowners.©FreescaleSemiconductor,Inc.2005.Slide1什么是PWM?periodonTTRatioWidthPulseTonToffTperiodAverage0%10%50%90%99%应用:D/A转换马达控制音调生成正弦波生成占空比=高电平时间/周期=Ton/TperiodTMFreescaleSemiconductorConfidentialandProprietaryInformation.Freescale™andtheFreescalelogoaretrademarksofFreescaleSemiconductor,Inc.Allotherproductorservicenamesarethepropertyoftheirrespectiveowners.©FreescaleSemiconductor,Inc.2005.Slide2PWM信号的产生(边缘对齐)开始周期TPWMTPWM占空比TDutyPWMDTYxPWMPERxPWMPERxfClock,TClock8-bitCounterPWMCNTx时钟8-bitCompare=PWMDTYx8-bitCompare=PWMPERx0x000x00ResetPin当8位计数器的值等于PWMDTY(dutycycle寄存器)时,电平从有效跳到无效;当8位计数器的值等于PWMPER(周期寄存器)时,电平从无效跳到有效,然后计数器清0,重新开始计数TMFreescaleSemiconductorConfidentialandProprietaryInformation.Freescale™andtheFreescalelogoaretrademarksofFreescaleSemiconductor,Inc.Allotherproductorservicenamesarethepropertyoftheirrespectiveowners.©FreescaleSemiconductor,Inc.2005.Slide3PWM模块特点8个带周期占空比可程控的PWM独立通道4个可程控选择的时钟源每个PWM通道有专用的计数器PWM每个通道脉冲极性可以选择每个PWM通道可使能/禁止周期和占空比双缓冲每个通道有中心对齐和边缘对齐方式分辨率:8位(8通道),16位(4通道)带中断功能的紧急切断工作模式TMFreescaleSemiconductorConfidentialandProprietaryInformation.Freescale™andtheFreescalelogoaretrademarksofFreescaleSemiconductor,Inc.Allotherproductorservicenamesarethepropertyoftheirrespectiveowners.©FreescaleSemiconductor,Inc.2005.Slide4PWM结构框图通道7周期和占空比计数器通道6周期和占空比计数器...通道0周期和占空比计数器管脚使能选择极性选择对齐方式选择管脚管脚TMFreescaleSemiconductorConfidentialandProprietaryInformation.Freescale™andtheFreescalelogoaretrademarksofFreescaleSemiconductor,Inc.Allotherproductorservicenamesarethepropertyoftheirrespectiveowners.©FreescaleSemiconductor,Inc.2005.Slide5PWM初始化步骤1.禁止PWMDisablePWMPWME2.选择时钟Selectclock(prescalerandscale)forthePWMPWMPRCLK,PWMSCLA,PWMSCLB,PWMCLK3.选择极性SelectpolarityPWMPOL4.选择对齐模式SelectcenterorleftalignedmodePWMCAE5.对占空比和周期编程ProgramdutycycleandperiodPWMDTYx,PWMPERx6.使能PWM通道EnableusedPWMchannelsPWMETMFreescaleSemiconductorConfidentialandProprietaryInformation.Freescale™andtheFreescalelogoaretrademarksofFreescaleSemiconductor,Inc.Allotherproductorservicenamesarethepropertyoftheirrespectiveowners.©FreescaleSemiconductor,Inc.2005.Slide6PWM时钟选择(1of4)1.ClockA(Ch0,Ch1,Ch4,Ch5)2.ClockSA(scaledA;Ch0,Ch1,Ch4,Ch5)3.ClockB(Ch2,Ch3,Ch6,Ch7)4.ClockSB(scaledB;Ch2,Ch3,Ch6,Ch7)4个时钟源:BusClockDividebyPrescalerTaps:248163264128预分频PWMPRCLK@$_03ClockSAClockSBClockAFurtherDivisionoftheclock:2468...512ClockBFurtherDivisionoftheclock:2468...512PWMSCLA@$_08PWMSCLB@$_09分频TMFreescaleSemiconductorConfidentialandProprietaryInformation.Freescale™andtheFreescalelogoaretrademarksofFreescaleSemiconductor,Inc.Allotherproductorservicenamesarethepropertyoftheirrespectiveowners.©FreescaleSemiconductor,Inc.2005.Slide7PWM时钟选择–预分频寄存器(2of4)0PCKB2PCKB1PCKB00PCKA2PCKA1PCKA0RWReset:00000000=UnimplementedorReservedPWMPRCLK@$_03PCKx2PCKx1PCKx0ValueofClockx000BusClock001BusClock/2010BusClock/4011BusClock/8100BusClock/16101BusClock/32110BusClock/64111BusClock/128可在任意时刻读写!x=AorB设置PRESCALE寄存器:PWMPRCLK=0x22;//B=Bus/4,A=Bus/4PWMPRCLK=0x07;//B=Bus,A=Bus/128SoftwareExamplesBit0Bit1Bit2Bit3Bit4Bit5Bit6Bit0TMFreescaleSemiconductorConfidentialandProprietaryInformation.Freescale™andtheFreescalelogoaretrademarksofFreescaleSemiconductor,Inc.Allotherproductorservicenamesarethepropertyoftheirrespectiveowners.©FreescaleSemiconductor,Inc.2005.Slide8PWM时钟选择–分频寄存器(3of4)总线时钟fBusDividebyPrescalerTaps:2481632641288-BitDownCounterBit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0PWMSCLx分频值SxClockxClockPWMSCLxPWMSCLxxClockSxClock_2_2__PWMSCLx=$00PWMSCLxvalueis256可在任意时刻读写!x=AorB/2ClockSxClockxClockx=fBus/PWMPRCLKCount=1PWMPRCLK@$_03PWMSCLB@$_09PWMSCLA@$_08例如:要求:ClockSx=1kHz总线时钟=16MHzPrescaler=128Prescaler=64Clockx=125kHzClockx=250kHzPWMSCLx=63PWMSCLx=125ClockSx=992HzClockSx=1000HzTMFreescaleSemiconductorConfidentialandProprietaryInformation.Freescale™andtheFreescalelogoaretrademarksofFreescaleSemiconductor,Inc.Allotherproductorservicenamesarethepropertyoftheirrespectiveowners.©FreescaleSemiconductor,Inc.2005.Slide9PWM时钟选择寄存器(4of4)PCLK6PCLK5PCLK4PCLK3PCLK2PCLK1PCLK0RWReset:00000000PWMCLK@$_02PCLK7选择时钟源:PCLK0=1;//SAissourceofch0PCLK6=0;//Bissourceofch6PWMCLK=0x11;//allchannels软件示例Bit0Bit1Bit2Bit3Bit4Bit5Bit6Bit0PCLK5—通道5时钟选择1=时钟源为SA0=时钟源为APCLK4—通道4时钟选择1=时钟源为SA0=时钟源为APCLK3—通道3时钟选择1=时钟源为SB.0=时钟源为BPCLK2—通道2时钟选择1=时钟源为SB0=时钟源为BPCLK1—通道1时钟选择1=时钟源为SA0=时钟源为APCLK0—通道0时钟选择1=时钟源为SA0=时钟源为APCLK7—通道7时钟选择1=通道7的时钟源为SB0=通道7的时钟源为B.PCLK6—通道6时钟选择1=时钟源为SB.0=时钟源为BTMFreescaleSemiconductorConfidentialandProprietaryInformation.Freescale™andtheFreescalelogoaretrademarksofFreescaleSemiconductor,Inc.Allotherproductorservicenamesarethepropertyoftheirrespectiveowners.©Free

1 / 21
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功