完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好!我正在研究一个项目,我需要两个外部触发异步计数器。我目前正在试用PIC18F26K80这个应用程序,我遇到了一个问题,使用time1进行计数。TMR1L和TMR1H总是在0,我还没有弄清楚为什么它们不会计数。我现在用1kHz的5V 50%占空比方波来触发测试。我用MCC生成了代码,我自己看不出任何问题。定时器1初始化下面的代码:定时器0工作至今。这里是MCC生成的初始化代码:任何帮助都将不胜感激!如果你推荐任何其他的微控制器来运行两个异步计数器,我愿意接受建议!谢谢你,迪伦
以上来自于百度翻译 以下为原文 Hello! I am working on a project in which I need two externally triggered asynchronous counters. I am currently experimenting with a PIC18f26k80 for this application and I am running into an issue with using Timer1 for counting. TMR1L and TMR1H are constantly at 0 and I have not been able to figure out why they will not count. I am triggering them right now with a 1KHz 5v 50% duty cycle square wave for testing. I've generated the code with MCC and do not see any problems myself. Timer 1 Initialize code posted below: void TMR1_Initialize(void) { //Set the Timer to the options selected in the GUI //T1CKPS 1:1; RD16 enabled; SOSCEN disabled; nT1SYNC do_not_synchronize; TMR1CS T1OSC/T1CKI; TMR1ON off; T1CON = 0x86; //T1GSS T1G; TMR1GE disabled; T1GTM disabled; T1GPOL low; T1GGO done; T1GSPM disabled; T1GVAL disabled; T1GCON = 0x00; //TMR1H 0; TMR1H = 0x00; //TMR1L 0; TMR1L = 0x00; // Load the TMR value to reload variable timer1ReloadVal=(TMR1H << 8) | TMR1L; // Clearing IF flag. PIR1bits.TMR1IF = 0; // Start TMR1 TMR1_StartTimer(); } Timer 0 is working great so far. Here is the MCC generated initialization code for that: void TMR0_Initialize(void) { // Set TMR0 to the options selected in the User Interface // T0PS 1:256; T08BIT 16-bit; T0SE Increment_lo_hi; T0CS T0CKI; TMR0ON off; PSA not_assigned; T0CON = 0x2F; // TMR0H 0; TMR0H = 0x00; // TMR0L 0; TMR0L = 0x00; // Load TMR0 value to the 16-bit reload variable timer0ReloadVal = (TMR0H << 8) | TMR0L; // Clearing IF flag INTCONbits.TMR0IF = 0; // Start TMR0 TMR0_StartTimer(); } Any help would be greatly appreciated! If you would recommend any other microcontrollers for running two asynchronous counters, I am open to suggestions! Thank You, Dylan |
|
相关推荐
3个回答
|
|
T1CKI是一个模拟能力的PIN,它是否已经切换到数字模式?
以上来自于百度翻译 以下为原文 T1CKI is an analog capable pin. Has it been switched to digital mode? |
|
|
|
它没有!只要把它设置为数字,它现在工作完美!非常感谢你的快速回复!
以上来自于百度翻译 以下为原文 It had not! Just set it to digital, and it works perfectly now! Thanks so much for your quick reply! |
|
|
|
一个很大的红旗是,你没有张贴任何代码来设置时钟输入引脚。当然,PIN默认输入上电,但我不喜欢信任默认…
以上来自于百度翻译 以下为原文 A big red flag was that you hadn't posted any code for setting up the clock input pins. Sure, pins default to input on power up, but I don't like trusting to defaults... |
|
|
|
只有小组成员才能发言,加入小组>>
5166 浏览 9 评论
2000 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3174 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2226 浏览 5 评论
734浏览 1评论
615浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
506浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
631浏览 0评论
528浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-24 16:08 , Processed in 1.284785 second(s), Total 79, Slave 63 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号