完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,这是我第一个使用PIC单片机的项目。我必须用超声波传感器来计算距离。我的程序工作得很好,我也在LCD显示器上打印我的结果。但我对我的决议并不满意。我使用20MHz晶体。所以我的内部频率是1/4。现在我的问题是我如何使用RA4/T0CKL输入来避免1/4 DeVIDER。我知道我必须设置在T0CON寄存器在T0CKL引脚过渡到1。但我如何连接我的20MHz到该引脚。我的外部频率来自哪里?我搜了很多,但什么也找不到。谢谢!问候
以上来自于百度翻译 以下为原文 Hello, its my first Project using a PIC Microcontroller. I have to calculate the distance with an ultrasonic sensor. My program works very well and i am also printing my result on a LCD Display. But i am not very happy with my resolution. I use a 20Mhz crystal. So my internal frequency is 1/4 of that. Now my question is how do i use the RA4/T0CKL input to avoid the 1/4 devider. I know i have to set in the T0CON register to 1 at Transition on T0CKL pin. But How do i connect my 20Mhz to that Pin. Where does my external frequency come from. I searched a lot but cant find anything. Thx for the Help! Greets |
|
相关推荐
1个回答
|
|
哇,真是个老古董。15年前开始使用PIC18S时,我使用了新的设备。最好的解决方案是升级到一个能在64 MHz运行的新芯片,并使用信号测量定时器获得64 MZZ分辨率。我怀疑你是在一个教育环境中,但是你必须使用你所得到的。你可以用40MHz的振荡器在40MHz上运行PIC18F252,并把你的分辨率提高一倍。外部频率来自你连接它的任何地方。如果你想在T0CKI上20MHz,那么你需要从某个东西得到一个20MHz的时钟。也许用振荡器代替20MHz晶体,同时从它同时驱动OSC1和T0CKI。请注意,图10-2和表22-8显示T0CKI不能比指令时钟快(20MHz/4),除非你使用预分频器来破坏你的目的。IO引脚到T0CKI,两者通过电阻输入时钟。这个想法是三态IO通常允许外部时钟通过T0CKI。当定时周期完成时,驱动IO低以覆盖外部时钟并停止时钟。然后脉冲它高/低,并计数有多少脉冲来翻转TMR0。它告诉你预分频器的值。我相信这是唯一的方法来获得更高的定时器分辨率与这个古老的设备。然后你可以在50MHz运行TMR0。
以上来自于百度翻译 以下为原文 Wow, what an old chip. I was using newer devices when I started with PIC18s 15 years ago. The best solution would be to upgrade to a newer chip that can run at 64Mhz, and use the Signal Measurement Timer to get 64MZz resolution. I suspect that you are in an education environment, however, where you have to use what you are given. You could run the PIC18F252 at 40MHz with a 40MHz oscillator and double your resolution. The external frequency comes from wherever you connect it. If you want 20MHz on T0CKI, then you need to have a 20MHz clock from something. Maybe replace the 20MHz crystal with an oscillator and drive both OSC1 and T0CKI from it. Note that figure 10-2 and table 22-8 shows T0CKI can't be faster than the instruction clock (20MHz/4) unless you use the prescaler which defeats your purpose. There is a trick I saw somewhere to connect another IO pin to T0CKI, and both to the input clock through a resistor. The idea was to tri-state the IO normally which allows the external clock through to T0CKI. Drive the IO low when the timing period is done to override the external clock and stop clocking. Then pulse it high/low and count how many pulses it took to rollover TMR0. That tells you the value in the prescaler. I believe this is the only way to get higher timer resolution with this ancient device. Then you can run Tmr0 at 50MHz. |
|
|
|
只有小组成员才能发言,加入小组>>
5163 浏览 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 01:43 , Processed in 1.300108 second(s), Total 79, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号