完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我正在使用PIC16LF15345,MPLABX 4.05,XC8 1.41和MCC 3的新项目。在系统模块中,选用1 MHz系统时钟除以4 MHz的HFIFTROC,TMR2模块用于PWM3,用HFIFToC时钟源将定时器周期设置为10 USEC。T2CKCONN=0x03,T2CONN=0x80,T2PR=0x27。但是时钟频率总是显示32.768 kHz。在PWM3模块中,占空比20%具有PWMDC值=31。PWM周期为0 s,PWM频率为0Hz,PWM分辨率为0位,并通过软件仿真器显示了20个指令周期的PWM波形(虽然预期10个周期)。PWM的时间是3个周期,具有1个周期的上升和下降时间。MCC是方便的,但不是有用的,因为它应该是明显的错误,如这些。[编辑]我添加了五个标签,但只有一个(PWM)被保存。?
以上来自于百度翻译 以下为原文 I am working on a new project using the PIC16LF15345, with MPLABX 4.05, XC8 1.41, and MCC 3. In the system module I chose HFINTOSC 4 MHz with divide by 4 for 1 MHz system clock. The TMR2 module is used for PWM3, and I set timer period to 10 uSec, with HFINTOSC clock source. T2CLKCON=0x03, T2CON=0x80, T2PR=0x27. But the Clock Frequency always displays 32.768 kHz. In the PWM3 module I have duty cycle 20% with PWMDC value = 31. But the PWM Period shows 0 s, PWM Frequency is 0 Hz, and PWM resolution is 0 bits. I built the project and using the software simulator shows the proper PWM waveform with period of 20 instruction cycles (although I expected 10 cycles). The PWM ON time is 3 cycles with 1 cycle rise and fall times. The MCC is convenient but not as useful as it should be with apparent errors such as these. [edit] I added five tags but only one (pwm) is saved ?? |
|
相关推荐
2个回答
|
|
我发现了一个警告,告诉我我需要为PWM的TMR2的时钟源选择FoS/4。但时钟频率仍然显示32.768 kHz。此外,在系统模块中,我必须设置OsCon寄存器的HFON位。在PIN模块中,我必须设置PWM3输出并清除该引脚(RC2)的安塞尔比特。在TMR2模块中,计时器周期显示它可以设置为4 USEC到1.024毫秒,因此我将其设置为10 USEC,并且将实际周期显示为40 USEC。在PWM3模块中,它显示20%的PWMDC值7,周期为40 USEC,频率为25 kHz,分辨率为5比特。我已经验证了实际的硬件显示了什么。这里是一个轻负载降压调节器的电感器的波形。
以上来自于百度翻译 以下为原文 I found a warning that told me I need to select FOSC/4 for the clock source of TMR2 for PWM. But the Clock Frequency still shows 32.768 kHz. Also in the System module I had to set the HFOEN bit of the OSCEN register. In the pin module I had to set PWM3 to output and clear the ANSEL bit for that pin (RC2). In the TMR2 module the timer period shows it can be set to 4 uSec to 1.024 mSec, so I set it to 10 uSec and it shows the actual period as 40 uSec. In the PWM3 module it shows PWMDC Value 7 for 20%, Period as 40 uSec, Frequency 25 kHz, and Resolution 5 bits. I have verified that the actual hardware does what is shown. Here is the waveform of the switch to the inductor of a lightly loaded buck regulator |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5166 浏览 9 评论
2000 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3174 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2226 浏览 5 评论
733浏览 1评论
615浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
505浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
631浏览 0评论
528浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-24 05:33 , Processed in 1.278643 second(s), Total 78, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号