完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我在PIC18F25K80上运行了一个代码,它运行一个测试台,并在一行中发送四个CAN消息。波特率是100KbPs,所以我在每个消息之间加了1ms的延迟。然而,偶尔,我得到了一个不需要的消息,但它是一个发送得更早的消息。发送缓冲器的E是错误发送的。还有其他人看到这种行为吗?
以上来自于百度翻译 以下为原文 I have code running on the PIC18F25K80 that is operating a test rig and sends four can messages in a row. The BAUD rate is 100kbps so I put a 1ms delay in between each message. However, occassionally, I get a message sent that is not required but is a message sent much earlier. Its almost as though one of the transmit buffer is SENT by mistake. Has anyone else seen this behaviour ? |
|
相关推荐
1个回答
|
|
嗨,罗宾,请你分享一下你的密码好吗?在传统模式下发送消息:测试缓冲区的txReq是否被清除。如果TXREQ被清除,则用值填充TX缓冲区ID和数据寄存器。将TXReq设置为“1”,以便将消息排队进行传输。请注意,TXReq只是一个发送请求位。设置此位意味着相应的传输缓冲器有待传输的消息。这并不保证消息在比特被设置之后立即被发送。“何时发送消息”的问题是基于发送优先级的。这取决于每个缓冲区的txReq位的轮询顺序。这里有一个例子说明了它是如何完成的:上面的代码片段是ECC遗留模式的MCC生成代码的一个例子。K80 ECAN已经在MCC中得到支持,我建议您使用这个工具来生成ECAN API和驱动程序。谢谢,Tam。
以上来自于百度翻译 以下为原文 Hi Robin, Can you share your code please? To transmit a message in legacy mode:
The question of "when the message would be transmitted" is based on the transmit priority. This depends on the order of polling of your TXREQ bits for each buffer. Here's an example of how it's done: uint8_t CAN_transmit(uCAN_MSG *tempCanMsg) { uint8_t tempEIDH = 0; uint8_t tempEIDL = 0; uint8_t tempSIDH = 0; uint8_t tempSIDL = 0; uint8_t returnValue = 0; if (TXB0CONbits.TXREQ != 1) { convertCANid2Reg(tempCanMsg->frame.id, tempCanMsg->frame.idType, &tempEIDH, &tempEIDL, &tempSIDH, &tempSIDL); TXB0EIDH = tempEIDH; TXB0EIDL = tempEIDL; TXB0SIDH = tempSIDH; TXB0SIDL = tempSIDL; TXB0DLC = tempCanMsg->frame.dlc; TXB0D0 = tempCanMsg->frame.data0; TXB0D1 = tempCanMsg->frame.data1; TXB0D2 = tempCanMsg->frame.data2; TXB0D3 = tempCanMsg->frame.data3; TXB0D4 = tempCanMsg->frame.data4; TXB0D5 = tempCanMsg->frame.data5; TXB0D6 = tempCanMsg->frame.data6; TXB0D7 = tempCanMsg->frame.data7; TXB0CONbits.TXREQ = 1; //Set the buffer to transmit returnValue = 1; } else if (TXB1CONbits.TXREQ != 1) { convertCANid2Reg(tempCanMsg->frame.id, tempCanMsg->frame.idType, &tempEIDH, &tempEIDL, &tempSIDH, &tempSIDL); TXB1EIDH = tempEIDH; TXB1EIDL = tempEIDL; TXB1SIDH = tempSIDH; TXB1SIDL = tempSIDL; TXB1DLC = tempCanMsg->frame.dlc; TXB1D0 = tempCanMsg->frame.data0; TXB1D1 = tempCanMsg->frame.data1; TXB1D2 = tempCanMsg->frame.data2; TXB1D3 = tempCanMsg->frame.data3; TXB1D4 = tempCanMsg->frame.data4; TXB1D5 = tempCanMsg->frame.data5; TXB1D6 = tempCanMsg->frame.data6; TXB1D7 = tempCanMsg->frame.data7; TXB1CONbits.TXREQ = 1; //Set the buffer to transmit returnValue = 1; } else if (TXB2CONbits.TXREQ != 1) { convertCANid2Reg(tempCanMsg->frame.id, tempCanMsg->frame.idType, &tempEIDH, &tempEIDL, &tempSIDH, &tempSIDL); TXB2EIDH = tempEIDH; TXB2EIDL = tempEIDL; TXB2SIDH = tempSIDH; TXB2SIDL = tempSIDL; TXB2DLC = tempCanMsg->frame.dlc; TXB2D0 = tempCanMsg->frame.data0; TXB2D1 = tempCanMsg->frame.data1; TXB2D2 = tempCanMsg->frame.data2; TXB2D3 = tempCanMsg->frame.data3; TXB2D4 = tempCanMsg->frame.data4; TXB2D5 = tempCanMsg->frame.data5; TXB2D6 = tempCanMsg->frame.data6; TXB2D7 = tempCanMsg->frame.data7; TXB2CONbits.TXREQ = 1; //Set the buffer to transmit returnValue = 1; } return (returnValue); } The snippet above is an example of MCC-generated code for ECAN legacy mode. The K80 ECAN is already supported in MCC and I suggest you use this tool to generate your ECAN APIs and drivers. Thanks, Tam |
|
|
|
只有小组成员才能发言,加入小组>>
5244 浏览 9 评论
2035 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3214 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2261 浏览 5 评论
779浏览 1评论
673浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
599浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
683浏览 0评论
580浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 18:22 , Processed in 1.265527 second(s), Total 78, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号