完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好!我在一个接收USAT数据的程序中工作。我不需要使用中断。目的是通过监视RCIF位来保持一个循环。当它被设置时,我将处理每一个收到的字节。从我理解的USAT中,每次读取RCREG时,RCIF位都被清除,然后我返回到循环的开始,等待一个新字节。这就是问题所在!RCIF位不会达到0!我已经做了所有的事情…我尝试读RCREG几次,我尝试零RCIF直接(PrI1BITS RCIF=0),但没有什么导致RCIF到零!……()PiL1ReC= GETCUTART();PutsCART(BytEyReC)ReD1=!LeD1……正在发生的事情是RCIF一直被清除。有人会对什么是错误的有什么建议吗?附加信息:C18汇编语言18F2520非常感谢蚂蚁提示。
以上来自于百度翻译 以下为原文 Hello guys! I am working in a program that receives USART data. I do not need to use the interrupt. The intent is to stay in a loop by monitoring the RCIF bit. When it's set, I'll handle every received byte. From what I understand from USART, every time I read RCREG the RCIF bit is cleared and then I go back to the beginning of the loop to wait for a new byte. That's the problem! The RCIF bit is not going to 0! I've done everything ... I try read RCREG several times, I try to zero RCIF directly (PIR1bits.RCIF = 0) but nothing causes RCIF to go to zero! . . . while (! PIR1bits.RCIF); byte_rec = getcUSART (); putcUSART (byte_rec) LED1 =! LED1 . . . What is happening is that RCIF is kept cleared all the time. Would anyone have any tips on what could be wrong? Additional Information: C18 compiler PIC18F2520 Thanks so much for ant hint. |
|
相关推荐
5个回答
|
|
这是对的,别费心了。数据表告诉您,该位是只读的。为什么调用函数只是为了读取寄存器?同样,您没有显示LeD1的定义。如果它正在处理一个PORTX寄存器,那么将其更改为等效的LATX寄存器。
以上来自于百度翻译 以下为原文 This is correct. Don't bother. As the datasheet tells you, that bit is read only. while (! PIR1bits.RCIF); byte_rec = getcUSART (); Why call a function just to read a register? Try: while (! PIR1bits.RCIF) byterec = RCREG; TXREG byterec; LED1 =! LED1 Also, you did not show the definition for LED1. If it is addressing a PORTx register, change it to the equivalent LATx register. |
|
|
|
如果您仍然无法解决,请张贴您的整个测试程序。
以上来自于百度翻译 以下为原文 If you still can't solve it, please post your ENTIRE test program. |
|
|
|
嗨,Q!B!非常感谢。我找到了问题所在。我的硬件使用了Mx85来从一个PIC通信到另一个PIC。我发现,当发射机PIC完成发送每个字节时,它将把它的Max55置于接收状态(将Re/DE置零)。这导致接收器的MAX55将其数据输出设为零。因此,在每个接收字节之后不久,接收PIC就已经知道新起始位和零位的所有字节的到达,但是没有停止位。但是,这又保持了RCIF位再次设置。你的答案是很重要的,我确认我的理解是在正确的轨道上,即使在那个时候,我仍然没有意识到这一特点运行McAc4.5谢谢。
以上来自于百度翻译 以下为原文 Hi qɥb! Thanks so much. I found where the problem was. My hardware used the MAX485 to communicate from one PIC to another. I found that when the transmitter PIC finished sending each byte, it would put its MAX485 in the receive state (putting RE / DE to zero). This caused the receiver's MAX485 to put its data output at zero. Thus, shortly after each received byte, the receiving PIC already understood the arrival of a new start bit and an all byte at zero, but without stop bits. But this then kept the RCIF bit set again. Your answer was important for me to confirm that my understanding was on the right track, even though at that time I still did not realize this feature of running the MAX485. Thanks. |
|
|
|
通常情况下,真正的问题是在最初的描述中没有提到的问题。:)
以上来自于百度翻译 以下为原文 So often, the real problem is something that wasn't mentioned in the initial description. :) |
|
|
|
哦,是的!很多时候,当你写这个问题时,你会遇到问题。事实并非如此。当我写这篇文章时,我想象着软件中的某些东西正在使RCIF一直保持不变。
以上来自于百度翻译 以下为原文 Oh yeah! Many times, when you write the problem, you encounter the problem. That was not the case. When I wrote the post, I was imagining that something in the software was causing RCIF to stay set all the time. |
|
|
|
只有小组成员才能发言,加入小组>>
5192 浏览 9 评论
2012 浏览 8 评论
1936 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3183 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2238 浏览 5 评论
746浏览 1评论
633浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
518浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
644浏览 0评论
544浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-1 13:59 , Processed in 1.317228 second(s), Total 84, Slave 68 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号