完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我使用的是DSPIC33 XC16。我试图理解Sosc是如何工作的。我有一个工作在8MHz的外部晶体。首先我需要理解的是这个频率有多少秒(或者我如何计算)。然后,我需要计算如何设计频率来创建示例1秒延迟。如果我使用PLL怎么办?我会用FoSC * 4频率来设计我的频率?PIC中的每一个命令每4赫兹执行一次吗?
以上来自于百度翻译 以下为原文 I'm using dspic33 xc16. I'm trying to understand how Sosc works. Example i have an external crystal which is working in 8mhz. First thing i need to understand is how many seconds(or how can i calculate) are this frequency. Then i need to calculate how can i devide my frequency for creating example 1 second delay. What if i will use PLL? i will devide my frequency with FOSC*4 frequency? Also every command in pic is executed every 4 hetz? |
|
相关推荐
10个回答
|
|
在你的问题中有很多问题,所以我试着把它们弄清楚。我想大多数的DSIC33设备在振荡器和计时器部分都是相同或非常相似的,但是知道你正在使用的实际设备是有用的。(基于这个假设,我使用了过去使用过的DSPIC33 EP512MU814,并有数据表。)二次振荡器(SOSC)被设计成在其上有一个32 kHz的晶体。因此,参考8MHz晶体必须参考主振荡器。为了将频率(赫兹测量)转换为周期(以秒为单位),可以使用公式:因此,8MHz的波形具有128n秒的周期。如果使用PLL(可以由主振荡驱动)。Tor或FRC,这是8MHz或子多),那么你需要计算Fosc的输入频率和各种分频器。数据表有这样的公式。一旦你有了Fosc,你就需要理解DSSPIC33设备每指令使用2个时钟脉冲。(你提到了一个4的因素——PIC18设备是这样)。因此,使用FoSC,将它除以2,将它转换为一个周期,这将告诉你每个指令将花费多长时间。(注意一些指令需要多个指令周期——例如,调用,GOTO -查看这些情况下的数据表。)如果你想要一个1秒的延迟,那么你需要选择合适的时钟源。如果使用SOSC(即32 kHz源),则可以使用Time1并将Primar设置为1:256(32768/256=128),然后将PR1设置为127。然后每秒都会超时。如果你喜欢的话,你可以使用其他PASCALAR/PR1组合。如果你使用其他定时器中的一个,那么你必须使用FoC/2的外围时钟。然后你需要知道你设置的Fosc值,选择一个适当的Primar值和PRX值,这样你就可以得到1秒的触发器。例如,如果Fosc是8MHz,并且选择1:256预刻度值,则PR2为4000000/256=15625。这足够小,以适应16位PRX寄存器。然而,如果你选择一个更高的FoSC,那么你可能需要设置一个定时器作为32位定时器S,你可以让PRXY寄存器对保持足够大的值。苏珊
以上来自于百度翻译 以下为原文 There are a number of things mixed up in your question so I;ll try to tease them out. I think most of the dsPIC33 devices are the same or very similar in the oscillator and timer sections but it would be useful to know the actual device you are using. (Based on this assumption, I'm using the dsPIC33EP512MU814 that I've used in the past and have the data sheet for.) The secondary oscillator (SOSC) is designed to have a 32KHz crystal on it. Therefore your reference to an 8MHz crystal must refer to the primary oscillator. To convert frequency (measured in Hertz) to period (measured in seconds) you can use the formula: frequency = 1/period Therefore 8MHz has a waveform that has a period of 128nSec. If you use the PLL (which can be driven by the primary oscillator or the FRC which is 8MHZ or a sub-multiple) then you need to calculate the Fosc based on the input frequency and the various dividers. The data sheet has the formula for this. Once you have Fosc, you need to understand that the dsPIC33 devices use 2 clock pulses per instruction. (You mention a factor of 4 - that is true for the PIC18 devices.) Therefore, take the Fosc, divide it by 2, convert it to a period and that will tell you how long each instruction will take. (Note that some instructions take multiple instruction cycles - e.g. call, goto - see the data sheet for these cases.) If you want a 1 second delay then you need to select the appropriate clock source. If you use the SOSC (i.e. the 32KHz source) then you can use Timer1 and set the prescalar to 1:256 (32768/256=128) and then set PR1 to 127. It will then timeout every second. You could use other prescalar/PR1 combinations if you like. If you use one of the other timers, then you must use the peripheral clock which is Fosc/2. You then need to know the Fosc value you have set up, select an appropriate prescalar value and a PRx value so that you get to your 1 second trigger. For example, if Fosc is 8MHz and you select a 1:256 prescalar value, then PR2 is 4,000,000/256=15,625. That is small enough to fit into the 16-bit PRx register. However if you choose a higher Fosc then you may need to set the timer up as a 32-bit timer s that you can have the PRxy register pair hold a big enough value. Susan |
|
|
|
非常感谢大家的全力解答。另一个问题是:我读到,每一个高脉冲都会增加计时器。因此,如果一个指令是2个时钟脉冲,那么我的定时器将增加每两个高脉冲?
以上来自于百度翻译 以下为原文 Thank you very help full answer. Another question is: I read that timer is increased every high pulse. So if an instruction is taking 2 clock pulses then my timer will be increased every two high pulses? |
|
|
|
你在哪里得到“高脉冲”?时钟边沿触发增量是学术性的,所以最好是说“时钟周期”苏珊已经提到你还没有透露你正在谈论的哪一个精确的PIC33设备。只是参考她所做的同一个设备,一个DSPIC33 EP512MU814,数据表说计时器2。9都是从“外围时钟”,这是FoC/2,只要你没有启用一个预分频器,那么,它将计数每两个振荡器时钟周期一次。
以上来自于百度翻译 以下为原文 Where did you get "high pulse" ? It's academic which clock edge triggers the increment, so it's better just to talk about "clock cycle" Susan already mentioned that you have not revealed which precise PIC33 device you are talking about. Just referring to the same device she did, a dsPIC33EP512MU814, the datasheet says that TIMERS 2-9 all run from the "Peripheral clock", which is Fosc/2. So long as you have not enabled a prescaler, then yes, it will count once every two oscillator clock cycles. |
|
|
|
采用次级振荡器32 MHz。在哪个时间执行32 MHz?我的意思是每秒32兆赫?
以上来自于百度翻译 以下为原文 Using the secondary oscillator 32Mhz. In which time 32mhz are executed? I mean 32mhz per second? |
|
|
|
这是苏珊已经告诉你的振荡器只设计为32千赫,千赫,而不是兆赫。
以上来自于百度翻译 以下为原文 This is the oscillator that Susan already told you is only designed to run at 32 kHz. The is KiloHertz, not MegaHertz |
|
|
|
所以,如果你在Time1上用一个32.768千赫的晶体连接到SOSC引脚,那么你需要知道的任何东西都在“图12-1:16-位Time1模块框图”中,你可以直接看到二次振荡器时钟TMR1,所以它将在一秒内计数32768次。
以上来自于百度翻译 以下为原文 So, if you are talking TIMER1 with a 32.768 kHz crystal attached to the SOSC pins, then everything you need to know is in "FIGURE 12-1: 16-BIT TIMER1 MODULE BLOCK DIAGRAM". You can see the secondary oscillator clocks TMR1 directly, so it will count 32768 times in one second. |
|
|
|
那么为什么我们不创造327?68的时间延迟呢?它将产生1秒的延迟。对吗?
以上来自于百度翻译 以下为原文 So why we dont create a delay of 32768 time? it will generate us 1 second delay. Right? |
|
|
|
这正是苏珊已经解释过的方法:
以上来自于百度翻译 以下为原文 That is exactly what Susan already explained how to do: |
|
|
|
对不起,我无法理解它,127秒=1秒?32768=256秒?
以上来自于百度翻译 以下为原文 Sorry but i cant undetstand it, 127=1 second? 32768=256 seconds? |
|
|
|
苏珊还说:“如果你喜欢的话,你可以使用其他PASCALAR/PR1组合。”她建议的方法类似于在只有8位定时器的小图片上使用的。步骤1是“将PASCALAR设置为1:256”,将传入时钟除以256,因此32768赫兹/ 256=128 HZSTATE 2是“WR”。一个定时器从零开始计数,直到计时器达到PR寄存器中的值。所以,如果你写127到PR1,它将从0计数到127,这是128个计数。除以128赫兹128给出一个赫兹,这是每秒一次,这就是你想要的。定时器,你可以让预分频器设置为“1:1”(即禁用),并将32767写入PR1。这将使它计数从0到32767,这是32768个计数,所以它会把传入时钟除以32768,这会给每秒一个周期。
以上来自于百度翻译 以下为原文 Susan also said "You could use other prescalar/PR1 combinations if you like." The method she suggested is similar to what is used on smaller PICs which only have 8 bit timers. Step #1 was "set the prescalar to 1:256" That would divide the incoming clock by 256, so 32768 Hz / 256 = 128 Hz Step#2 was "write 127 to PR1". A timer starts counting from zero, until the timer reaches the value in the PR register. So, if you write 127 to PR1, it will count from 0 to 127, which is 128 counts. Dividing 128 Hz by 128 gives one Hertz, which is once per second, which is what you want. As the DSPIC33 has a 16 bit timer, you could just leave the prescaler set to "1:1" (i.e. disabled), and write 32767 to PR1. That would make it count from 0 to 32767, which is 32768 counts, so it would divide the incoming clock by 32768, which would give one cycle per second. |
|
|
|
只有小组成员才能发言,加入小组>>
5160 浏览 9 评论
1998 浏览 8 评论
1927 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3170 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2225 浏览 5 评论
729浏览 1评论
613浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
503浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
628浏览 0评论
526浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 09:26 , Processed in 1.674556 second(s), Total 97, Slave 80 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号