完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
以下是PWM的配置,配置为UPDOWN的时候,可以用示波器观察到波形,配置为UP的时候不能观察到波形
以下是配置为UP的PWM配置 void InitEPwm7Example() [ EPwm7Regs.TBPRD = 1000; // Set timer period 6000 408 EPwm7Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0 EPwm7Regs.TBCTR = 0x0000; // Clear counter // Setup TBCLK EPwm7Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up EPwm7Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading EPwm7Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT EPwm7Regs.TBCTL.bit.CLKDIV = TB_DIV1; // TB_DIV4 = 0x02 EPwm7Regs.TBCTL.bit.PRDLD = TB_SHADOW; EPwm7Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN; EPwm7Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; // Load registers every ZERO EPwm7Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW; EPwm7Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; EPwm7Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // Setup compare EPwm7Regs.CMPA.half.CMPA = 500; //3000 // Set actions EPwm7Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM1A on CAU EPwm7Regs.AQCTLA.bit.CAD = AQ_CLEAR; // Clear PWM1A on CAD EPwm7Regs.AQCTLB.bit.CAU = AQ_CLEAR; // Clear PWM1B on CAU EPwm7Regs.AQCTLB.bit.CAD = AQ_SET; // Set PWM1B on CAD // Active Low PWMs - Setup Deadband // EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; // EPwm1Regs.DBCTL.bit.IN_MODE = DBA_ALL; // EPwm1Regs.DBRED = EPWM1_MIN_DB; // EPwm1Regs.DBFED = EPWM1_MIN_DB; // EPwm1_DB_Direction = DB_UP; // Interrupt where we will change the Deadband EPwm7Regs.ETSEL.bit.INTSEL = ET_CTRU_CMPA; // Select INT on Zero event EPwm7Regs.ETSEL.bit.INTEN = 1; // Enable INT EPwm7Regs.ETPS.bit.INTPRD = ET_1ST; // Generate INT on 3rd event // EPwm1Regs.ETSEL.bit.SOCAEN = 1; // Enable SOC on A group // EPwm1Regs.ETSEL.bit.SOCASEL = 3; // Select SOC from CMPA on upcount // EPwm1Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event ] |
|
相关推荐
5 个讨论
|
|
lizhongrui 发表于 2018-9-10 07:36 您好 Igor An 已经按你说的更改了但是还无法观察到波形。 PWM IO初始化 void InitEPwm7Gpio(void) [ EALLOW; /* Disable internal pull-up for the selected output pins for reduced power consumption */ // Pull-ups can be enabled or disabled by the user. // This will enable the pullups for the specified pins. // Comment out other unwanted lines. GpioCtrlRegs.GPAPUD.bit.GPIO30 = 1; // Disable pull-up on GPIO30 (EPWM7A) // GpioCtrlRegs.GPBPUD.bit.GPIO40 = 1; // Disable pull-up on GPIO40 (EPWM7A) // GpioCtrlRegs.GPBPUD.bit.GPIO58 = 1; // Disable pull-up on GPIO58 (EPWM7A) // GpioCtrlRegs.GPBPUD.bit.GPIO41 = 1; // Disable pull-up on GPIO41 (EPWM7B) // GpioCtrlRegs.GPBPUD.bit.GPIO44 = 1; // Disable pull-up on GPIO44 (EPWM7B) /* Configure EPWM-7 pins using GPIO regs*/ // This specifies which of the possible GPIO pins will be EPWM7 functional pins. // Comment out other unwanted lines. GpioCtrlRegs.GPAMUX2.bit.GPIO30 = 3; // Configure GPIO30 as EPWM7A // GpioCtrlRegs.GPBMUX1.bit.GPIO40 = 1; // Configure GPIO40 as EPWM7A // GpioCtrlRegs.GPBMUX2.bit.GPIO58 = 3; // Configure GPIO58 as EPWM7A // GpioCtrlRegs.GPBMUX1.bit.GPIO41 = 1; // Configure GPIO41 as EPWM7B // GpioCtrlRegs.GPBMUX1.bit.GPIO44 = 3; // Configure GPIO44 as EPWM7B EDIS; ] PWm初始化更改为 void InitEPwm7Example() [ EPwm7Regs.TBPRD = 1000; // Set timer period 6000 408 EPwm7Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0 EPwm7Regs.TBCTR = 0x0000; // Clear counter // Setup TBCLK EPwm7Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up EPwm7Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading EPwm7Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT EPwm7Regs.TBCTL.bit.CLKDIV = TB_DIV1; // TB_DIV4 = 0x02 EPwm7Regs.TBCTL.bit.PRDLD = TB_SHADOW; EPwm7Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN; EPwm7Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; // Load registers every ZERO // EPwm7Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW; EPwm7Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // EPwm7Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // Setup compare EPwm7Regs.CMPA.half.CMPA = 500; //3000 // Set actions // EPwm7Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM1A on CAU EPwm7Regs.AQCTLA.bit.CAD = AQ_SET; // Clear PWM1A on CAD EPwm7Regs.AQCTLA.bit.ZRO = AQ_CLEAR; // EPwm7Regs.AQCTLB.bit.CAU = AQ_CLEAR; // Clear PWM1B on CAU // EPwm7Regs.AQCTLB.bit.CAD = AQ_SET; // Set PWM1B on CAD // Active Low PWMs - Setup Deadband // EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; // EPwm1Regs.DBCTL.bit.IN_MODE = DBA_ALL; // EPwm1Regs.DBRED = EPWM1_MIN_DB; // EPwm1Regs.DBFED = EPWM1_MIN_DB; // EPwm1_DB_Direction = DB_UP; // Interrupt where we will change the Deadband EPwm7Regs.ETSEL.bit.INTSEL = ET_CTRU_CMPA; // Select INT on Zero event EPwm7Regs.ETSEL.bit.INTEN = 1; // Enable INT EPwm7Regs.ETPS.bit.INTPRD = ET_1ST; // Generate INT on 3rd event // EPwm1Regs.ETSEL.bit.SOCAEN = 1; // Enable SOC on A group // EPwm1Regs.ETSEL.bit.SOCASEL = 3; // Select SOC from CMPA on upcount // EPwm1Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event ] 还是无法输出波形?这个是啥原因造成的呢? |
|
|
|
|
|
lizhongrui 发表于 2018-9-10 07:36 我想问一下,现在设置的PWM是向上计数的,中断配置如下 EPwm7Regs.ETSEL.bit.INTSEL = ET_CTRU_CMPA; // Select INT on Zero event EPwm7Regs.ETSEL.bit.INTEN = 1; // Enable INT EPwm7Regs.ETPS.bit.INTPRD = ET_1ST; // Generate INT on 3rd event 中断里面有一个IO翻转,但是测得IO频率是PWM频率的一半,这个是什么原因造成的呢??? |
|
|
|
|
|
只有小组成员才能发言,加入小组>>
315 浏览 1 评论
518 浏览 2 评论
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
758 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
643 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1115 浏览 1 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
9浏览 28评论
17浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
232浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
191浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
51浏览 13评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-19 19:03 , Processed in 0.785410 second(s), Total 56, Slave 48 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号