完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我使用PIC18F46K22的UART2与“CCTALL”协议通信。该协议只提供1线(TX和RX)双向通信。由于这个协议的特定硬件,所有字节发送也在读取。我已经尝试过,在开始传输之前清除RCIE比特,并使用TXIF的最后一个插入来设置RCIE到1,但是它仍然是一个字节(传输的最后一个),并且它使接收同步。(1字节)。是否可以禁用接收ItUPT直到最后一个字节的传输结束。(因为TXIF在发送缓冲区空闲但不在字节传输结束时进行中断)。
以上来自于百度翻译 以下为原文 hello, I use the uart2 of a pic18F46K22 for communication with "CcTalk" protocol. this protocol gives a bi-direction communication with only 1 wire (TX and RX). due to this particular hardware of this protocol, all byte sending are also reading. I would like to disable the reception during the transmision. I have tried, to clear RCIE bit just before beginning the transmision and to use the last interupt of TXIF for set the RCIE to 1. but it still one byte (the last of the transmision) and it de-synchronises the reception. (of 1 byte). is it possible to disable the reception interupt until the end of the transmission of the last byte. (because TXIF do an interupt when the sending buffer is free but not at the end of the transmistion of a byte). tanks for your help. |
|
相关推荐
10个回答
|
|
您是否尝试过通过清除RCTAST2寄存器中的CREN位来禁用USAT接收器(而不是中断)?
以上来自于百度翻译 以下为原文 Have you tried just disabling the USART receiver (NOT the interrupt) by clearing the CREN bit in the RCSTA2 register? |
|
|
|
下面是更多的信息:从数据表:在发送最后一个字节后检查TXSTA2BIT.TrMT值,以确定何时重新启用接收器。
以上来自于百度翻译 以下为原文 Here is some more info: From the datasheet: After you transmit the last byte examine the TXSTA2bit.TRMT value to determine when to re-enable the receiver. |
|
|
|
请注意,禁用RCIE意味着接收器将溢出,所以当完成发送时,您将不得不切换CREN ON ON,以清除错误条件。+ 1使用TrMT来检测传输已经完成,而不是TXIF。这是大多数PICS无法中断的巨大痛苦。关于TrMT的真实性。
以上来自于百度翻译 以下为原文 Be aware, disabling RCIE means that the receiver will be overflowing, so you will have to toggle CREN off and on when you finish transmitting to clear the error condition. +1 for using TRMT to detect the transmission has finished, not TXIF. It is a great pain that most PICs are not able to interrupt on TRMT going true. |
|
|
|
我不熟悉CcTalk,但LIN协议是同一种类型的,与一条线双向通信。为什么不接收字节并检查它们与正在发送的匹配吗?接通和关断风险的同步和合成帧错误的损失。
以上来自于百度翻译 以下为原文 I'm not familiar with CcTalk, but the LIN protocol is of the same type, bi-directional communication with one wire. Why not just receive the bytes and check that they match what is being sent? Turning a receiver on and off risks loss of synchronization and resultant framing errors. GlennP |
|
|
|
在这个时刻,我使用了一个标志。1)我把这个标志放在“发送状态”之前,在最后一个TX IMPUT之前,我把标志放在RX Iutut中的“最后一个字节发送状态”中,我读取了所有接收到的用于清除RXRG的字节,但是忽略了T时接收到的字节。HE标志处于“发送状态”。如果标志位于“最后字节发送状态”,则将该标志放在“读取状态”上,忽略刚才读取的字节。在“读取状态”下将接收到带有标志的下一个字节。我将尝试用TrMT位使用我的标志来删除该过程。
以上来自于百度翻译 以下为原文 tanks for your answer. for this moment, I use a flag. 1) I put this flag to "sending state" just before begining the transmission 2) at the last TX interupt I put the flag to "last byte sending state" in the rx interupt, I read all byte received for clearing RXREG but disregard the byte received when the flag is in "sending state". if the flag is in "last byte sending state", I put this flag on "reading state" and disregard the byte just reading. the next byte receive with flag in "reading state" will be interpreted. I will try to remove the procedure using my flag with the TRMT bit. |
|
|
|
很好。只要协议不能导致冲突,忽略所接收的字节就可以了。在LIN协议中,冲突是可能的,发送节点读取它们的接收UART以确定它们发送的是什么。[如果不是的话,很可能是碰撞,它们停止传播。]
以上来自于百度翻译 以下为原文 Good. As long as the protocol cannot result in a collision, ignoring the bytes received is fine. In the LIN protocol, collisions are possible and transmitting nodes read their receive UARTs to determine if what they have sent is what's on the line. [If not, it's likely a collision and they stop transmitting.] GP |
|
|
|
这正是我们对CcTalk所做的,那么你知道消息的传输是完整的。
以上来自于百度翻译 以下为原文 tha'ts exactly what we do with cctalk, then you know the transmission of the message is complete |
|
|
|
CcTalk只能碰撞,如果你有2个相同地址的外设-它是一个主/许多奴隶和主人启动过程。
以上来自于百度翻译 以下为原文 CCTalk can only collide if you have 2 peripherals with the same address - it's one master/ many slaves and master initiates the process |
|
|
|
这是一个很好的方法,但是,在最后一个TX中断之后,您可能会收到两个字节。当TXIF变高时,TXREG的字节才刚刚被传输到传输移位寄存器。如果您设法在字节完成发送之前将最终值写入TXRG,则YO。在将标志设置为“最后一个字节发送状态”之后,U将接收第二个最后一个字节和最后一个字节。
以上来自于百度翻译 以下为原文 That is a pretty good way to do it, EXCEPT, you will probably receive two bytes after the last TX interrupt. When TXIF goes high, the byte in TXREG has only just been transferred to the transmit shift register. If you manage to write the final value to TXREG before that byte finished sending, then you will receive that second last byte, and the last byte, AFTER you set your flag to "last byte sending state". |
|
|
|
非常感谢你的帮助,现在使用的是TrMT位,它工作得很好。我总是读RXRG字节来清除ANTIF TrMT=1。我使用字节,如果不是,我不理会字节。在Futuri中,我将检查用TrMT=0接收的字节是否与这些传输相同。
以上来自于百度翻译 以下为原文 Tanks you very much for your help, In use now the TRMT bit and that work very fine. I read always the RXREG byte for clearing and if the TRMT = 1 I use the byte if not I disregard the byte. in the futur i will check if the byte received with TRMT = 0 are the same that these one transmit. |
|
|
|
只有小组成员才能发言,加入小组>>
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 18:13 , Processed in 1.369504 second(s), Total 98, Slave 81 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号