完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
关于以下代码中 PDC1 = PHASE1 / 2; // Initialize as 0 voltage 应该是50%占空比 为什么注释中注释的是0%占空比0V电压?是我理解错了?
/********************************************************************* Function: void InitMCPWM(void) PreCondition: None. Input: None. Output: None. Side Effects: None. Overview: InitMCPWM, intializes the PWM as follows: 1. FPWM = 20000 hz 2. Complementary PWMs with center aligned 3. Set Duty Cycle to 0 for complementary, which is half the period 4. Set ADC to be triggered by PWM special trigger 5. Configure deadtime to be 2 us Note: None. ********************************************************************/ void InitMCPWM(void) { PHASE1 = (FCY/FPWM - 1); PHASE2 = (FCY/FPWM - 1); PHASE3 = (FCY/FPWM - 1); IOCON1 = 0; IOCON2 = 0; IOCON3 = 0; DTR1 = 0x0000; // 2 us of dead time DTR2 = 0x0000; // 2 us of dead time DTR3 = 0x0000; // 2 us of dead time ALTDTR1 = 2*ALTDTR_DIV2; // 2 us of dead time ALTDTR2 = 2*ALTDTR_DIV2; // 2 us of dead time ALTDTR3 = 2*ALTDTR_DIV2; // 2 us of dead time //Note: ALTDTR_DIV2 define in svm.c should be half of ALTDTRx PTCON2 = 0x0000; // Divide by 1 to generate PWM PWMCON1 = 0x0604; // Enable PWM output pins and configure them as PWMCON2 = 0x0204; // complementary mode PWMCON3 = 0x0204; PDC1 = PHASE1 / 2; // Initialize as 0 voltage PDC2 = PHASE2 / 2; // Initialize as 0 voltage PDC3 = PHASE3 / 2; // Initialize as 0 voltage SEVTCMP = 1; // Enable triggering for ADC //fault enabled FCLCON1 = 0x0005; FCLCON2 = 0x0005; FCLCON3 = 0x0005; PTCON = 0x8000; // start PWM return; } |
|
相关推荐
1个回答
|
|
这是一段PWM初始化程序吧,不是控制程序
|
|
|
|
只有小组成员才能发言,加入小组>>
求解外围电路实现的是4脚给持续低电平复位并正常工作,高电平不工作的原因
2084 浏览 1 评论
3629 浏览 3 评论
PIC1946程序有一个变量在运行过程中恢复初始值其他变量保持不变
2336 浏览 2 评论
2763 浏览 0 评论
PIC16F1825的RC5引脚,在主程序中操作无效,在中断中可以改变是为什么?
4027 浏览 5 评论
973浏览 0评论
用XC8编译PIC18F25K80时提示下面Error,求怎么解决这个问题
6360浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-4 00:16 , Processed in 0.809369 second(s), Total 78, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号