1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我需要生成一个13MHz时钟输出来运行一个外部设备,所以我试图用MCC配置OC1。我的配置是:FoC/2=52MHZand,我在MCC中配置了OC1,如所附的屏幕截图。我看到的是OC1引脚上产生的PWM具有较低的频率;我不能测量。在我的范围内,但我确信它比连接设备的性能要低13MHz(运行速度较慢)。我认为OCX是基于硬件的,所以可以使用FoS/2作为输入产生的最大PWM频率是OFC/ 4(设置第一比较值=0x00 01和第二比较值=0x00)。02)。我尝试过这个值(只是为了测试),输出频率与我使用第一=0x00 02和第二=0x000 04.我做错什么一样吗?最大OCX频率有其他限制吗?还是MCC问题?我使用MPLAB X V3.45和MCC V3.25与PIC24EP512GP204。谢谢,尼古拉
以上来自于百度翻译 以下为原文 Hi all, I need to generate a 13MHz clock output to run an external device so I'm trying to configure the OC1 with MCC. My configuration is: Fosc/2 = 52MHz and I configured OC1 in MCC as in the attached screenshot. What I saw is that the generated PWM on OC1 pin has lower frequency; I'm not able to measure it with my scope but I'm sure it's less then 13MHz from the behaviour of the connected device (that run slower). I thought that the OCx was hardware based so the maximum PWM frequency I could generate using Fosc/2 as input is Fosc/4 (setting 1st compare value = 0x0001 and 2nd compare value = 0x0002). I tried this values too (just to test) and the output frequency remained the same as when I used 1st=0x0002 and 2nd=0x0004. Am I doing something wrong? Is there some other limitations about maximum OCx frequency? Or is it an MCC issue? I'm using MPLAB X v3.45 and MCC v3.25 with PIC24EP512GP204. Thanks in advance, Nicola Attached Image(s) |
|
相关推荐
8个回答
|
|
在此期间,我正在等待您的帮助,以更好地理解OCx限制,我找到了另一种方式(也许是更好的方式)来实现目标。我想使用“参考时钟生成器”将Fosc除以8(以RODIV设置)映射到一个RPn管脚,但我无法找到如何在MCC中设置RPn管脚。我在系统模块-寄存器窗口中找到了设置REFOCON寄存器值的方法,但我不知道如何将REFCLKO映射到某个管脚。我看到了将OSC2启用为CLKO的可能性,但我认为这是不同的(实际上这消除了使用外部晶体的可能性)……是真的吗?非常感谢大家的支持!问候,尼古拉
以上来自于百度翻译 以下为原文 In the meantime I'm waiting your help to understand better the OCx limits I found another way (maybe a better way) to reach the goal. I'm thinking to use the "Reference Clock Generator" to map the Fosc, divided by 8 (set in RODIV), to a RPn pin but I'm not able to find how to set the RPn pin in MCC. I found the way to set REFOCON register value in the System Module - Registers window but I don't know how to map REFCLKO to a certain pin. I saw there is the possibility to enable OSC2 as CLKO but I think this is a different thing (infact this removes the possibiliy to use an external crystal)...is it true? Thanks a lot for any support!! Regards, Nicola |
|
|
|
更新:如果为REFCLKO设置RPn pin,则在代码生成之后,在“pin_manager.c”文件的“Set the PPS”部分中手动添加以下行:RPOR5bit.RP54R=0x0031;//RC6->RCG:REFCLKO;它正常工作,但是如果我试图使用MCC设置它,则在Pin模块寄存器中设置RP54R=0x31窗户,不管用。我在窗口MCC中看到RP54R的改变,只是更新了“*.mc3”文件:
以上来自于百度翻译 以下为原文 UPDATE: if I set RPn pin for REFCLKO adding the following line manually in "Set the PPS" section of "pin_manager.c" file after the code generation: RPOR5bits.RP54R = 0x0031; //RC6->RCG: REFCLKO; it works properly but if I try to set it using MCC, setting RP54R = 0x31 in the Pin Module - Registers windows, it doesn't work. I saw changing RP54R in that window MCC just update the "*.mc3" file: but this file is just used to load the saved config when opening MCC.....but with code generation it doesn't edit "Set the PPS" section of "pin_manager.c" adding the line above. Thanks, Nicola |
|
|
|
嗨,用Fosc/2作为52Mhz,主比较值和次比较值分别是1和2,PWM时钟频率应该是13Mhz。我不知道最大频率的任何限制。我们将很快检查并回复您。谢谢,Ramya
以上来自于百度翻译 以下为原文 Hi, With Fosc/2 as 52Mhz and primary and secondary compare value as 1 and 2 respectively, the PWM clock frequency should be 13Mhz. I am not aware of any limitation for max frequency. We will check and get back to you on this soon. Thanks & Regards, Ramya |
|
|
|
比较值分别为1和2,我预期PWM时钟频率=26MHz……MCC中的RIFCKO问题是什么?
以上来自于百度翻译 以下为原文 With compare values as 1 and 2 respectively I expected a PWM clock frequency = 26MHz. ...and what about the REFCLKO issue in MCC? |
|
|
|
不正确。也不正确。这是交易……对于52MIPS外围时钟:对于OC1R=1,准时为2/52e6=(大约)38.4ns对于OC1RS=2,周期为3/52e6=(大约)57.7ns。频率=(大约)17.3 MHZ测试在我的PIC24EP256GP202上。在我的范围内观察到(大约)时间。我无法想象在没有作用域的情况下调试这些微调的寄存器设置,我完全同情那些没有作用域的人。请注意这个特定的PWM模块的“经典”计时器设置:在计算相对于r的定时时时时不要忘记向寄存器设置中添加1评价值。您可能不会注意到(见鬼,您甚至可能无法在“范围”上观察与较大的寄存器设置(比如1000和2000)的区别,但是对于这些小值来说很容易看到。但是必须注意,对于OC1R=2和OC1RS=4,我观察到周期=(大约)96.1ns,准时=(大约)57.7ns。这和上面的计算方法是一致的。这是我的PWM代码(自由模式下的XC16版本1.26)底线:我想是17.3……MHz是使用PIC24FxxxGP2x系列上的PWM模块所能获得的最快输出。具体地说:OC1R必须大于零,OC1RS必须大于OC1R,所以1、2是它所能获得的最佳输出。
以上来自于百度翻译 以下为原文 Not true. Also not correct. Here's the deal... For 52 MIPS peripheral clock:
Note the "classical" timer settings for this particular PWM module: Don't forget to add 1 to the register setting when calculating the timing relative to the register value. You might not notice (heck, you might not even be able to observe on a 'scope) the difference with larger register settings such as 1000 and 2000, but for these small values easy to see. But you do have to look. Note that with OC1R = 2 and OC1RS = 4, I observe that period = (approximately) 96.1 ns and on-time = (approximately) 57.7 ns. That's consistent with method of the above calculations. Here's my PWM code (XC16 version 1.26 in Free mode) // Tested by davekw7x on a PIC24EP256GP202 running at 52 MIPS // // OC1 in standard PWM on Pin 21 of the DIP-28 // Pin 21 is RB10/RP42 // OC1 function number is 0b010000 (Table 11-3) void initPwm(void) { // Unlock the IOLOCK so that can do pin assignment __builtin_write_OSCCONL(OSCCONL & 0xbf); RPOR4bits.RP42R = 0b010000; // Set to default values for starters OC1CON1 = 0; OC1CON2 = 0; // Select OC1 clocked by peripheral clock OC1CON1bits.OCTSEL = 0b111; // On-time OC1R = 1; // Period OC1RS = 2; // Self synchronized OC1CON2bits.SYNCSEL = 0b11111; // Finally: start in Aligned PWM mode OC1CON1bits.OCM = 0b110; } Bottom line: I think 17.3... MHz is the fastest output that you can get with the PWM module on the PIC24FxxxGP2xx family. Specifically: OC1R must be greater than zero, and OC1RS must be greater than OC1R, so 1, 2 is the best that it can get. Regards, Dave |
|
|
|
非常感谢你的解释!我忘了把1加到寄存器值上……所以为了得到占空比50%的13MHz时钟,我只需要在OC1R和OC2R中设置1和3。如果你看一下附在第一篇文章上的图片,你会发现OCxR值的计算时间是错误的。它们的计算值不加1的寄存器值。你同意我在MCC计算中存在的问题吗?你检查过RefCKO问题了吗?再次感谢尼古拉
以上来自于百度翻译 以下为原文 Thank you very much for the explanation! I forgot to add 1 to the register value...so to obtain 13MHz clock with 50% duty cycle I just have to set 1 and 3 in OC1R and OC2R. I think I was misled by the wrong calculation made by MCC. If you look at the picture attached to the 1st post you can see that the calculated times for that OCxR values were wrong.. They are calculated without add 1 to the registers values. Do you agree with me there is an issue in the MCC calculation? Did you check the REFCLKO issue too? Thanks again, Nicola |
|
|
|
在http://www..hip.com/for./m959967.aspxi.e.非常粗心的MCC编程中,看起来与您的另一个问题非常相似。
以上来自于百度翻译 以下为原文 Seems like a very similar issue to your other one at http://www.microchip.com/forums/m959967.aspx i.e. very careless programming in MCC. |
|
|
|
您好,我同意MCC中所示的OC计算是错误的,下次发布时将予以更正。给您带来不便,敬请原谅。
以上来自于百度翻译 以下为原文 Hi, I agree the OC calculation shown in MCC is wrong and will be corrected in next release. Sorry for the inconvenience caused. |
|
|
|
只有小组成员才能发言,加入小组>>
5242 浏览 9 评论
2031 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3207 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2256 浏览 5 评论
778浏览 1评论
666浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
595浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
677浏览 0评论
576浏览 0评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 12:28 , Processed in 1.427647 second(s), Total 89, Slave 73 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号