完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
在12F1572中使用PWM1,可以得到恒定的PWM。但是,动态改变频率有困难。我试着交换ENable和OutputEnable代码,但是没有乐趣。
以上来自于百度翻译 以下为原文 Using PWM1 in a 12F1572 I can get a constant PWM. However, I am having trouble dynamically changing the frequency. I tried interchanging the ENable and the OutputEnable code but no joy. BANKSEL APFCON movlw 1 ; RA5 = PWM1 movwf APFCON ; initialize PWM registers BANKSEL PWM1CLKCON movlw b'10' ; select LFINTOSC, no prescaler movwf PWM1CLKCON movlw (0< clrf PWM1PHH ; start period at phase = 0 clrf PWM1PHL bsf PWM1CON, EN ; ENable PWM1 Loop ; set period to 400HZ and duty cycle to 50% BANKSEL PWM1PRH clrf PWM1PRH ; end period at count = 77 = 400Hz movlw .76 ; (divides by N+1) movwf PWM1PRL clrf PWM1DCH ; set duty cycle to 50% movlw .38 movwf PWM1DCL BANKSEL PWM1CON bsf PWM1CON, OE ; ENable PWM1 movlw .50 ; set pulse width to 50msec call DelayMsec call Run.T1 ; delay bcf PWM1CON, OE ; DISable PWM1 movlw .50 ; set pulse width to 50msec call DelayMsec BANKSEL PWM1PRH clrf PWM1PRH ; 800Hz movlw .38 ; (divides by N+1) movwf PWM1PRL clrf PWM1DCH ; set duty cycle to 50% movlw .19 movwf PWM1DCL BANKSEL PWM1CON bsf PWM1CON, OE ; ENable PWM1 movlw .50 ; set pulse width to 50msec call DelayMsec BANKSEL PWM1CON bcf PWM1CON, OE ; DISable PWM1 movlw .50 ; set pulse width to 50msec call DelayMsec goto Loop |
|
相关推荐
2个回答
|
|
您没有提到在尝试此代码时发生了什么。您也没有显示配置位,也没有提到是否禁用了WDT。
以上来自于百度翻译 以下为原文 You did not mention what happens when you try this code. You also didn't show your config bits, or mention if you have disabled the WDT. |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5003 浏览 9 评论
1921 浏览 8 评论
1852 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3066 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2143 浏览 5 评论
574浏览 1评论
431浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
475浏览 0评论
367浏览 0评论
IPECMD命令烧录AVR128DA48芯片,报找不到芯片错误
852浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-8-16 13:46 , Processed in 1.084978 second(s), Total 78, Slave 63 queries .
Powered by 电子发烧友网
© 2015 www.ws-dc.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191