完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我正在使用:PIC24FJ256GA705好奇心开发板,带有一个M2323-GT;RS232--GT;USB连接到PC适配器,连接到UC内部的UART1模块。我已经设法把传输传送到PC,但是在每次传输之后都有一些随机字符是杂乱无章的。(如图所示)有人能解释一下为什么会出现在这里吗?如果你能指出我的代码中的任何错误和可能的改进,我将非常感激。我为代码的长度道歉,我已经删除了大部分不相关的代码。对不起,如果我的格式不是很好,这是我的第一个论坛帖子。(张贴说,访问被拒绝,所以编辑帖子一旦张贴)感谢任何帮助!实际上,它现在在实际数据之前发送一些随机字符。传输之间的时间也不一致(第一LED闪烁,延迟,闪烁闪烁)(TX LED),我看不出为什么它会永远循环?串口阅读器图像不会上载,所以我会尝试上传一个回复。P.S.如果你看到这个,DarioG你居然帮助了难以置信地不知道它。我非常感谢你对这些论坛的贡献!
以上来自于百度翻译 以下为原文 Hi, I am using: PIC24FJ256GA705 Curiosity development board, with a Max2323 -> RS232 -> USB into PC adapter, connected to the UART1 module inside the uC. I have managed to get the transmission to PC, but after every transmission there are some random characters that are gibberish. (shown in picture) Please could someone explain why these are here? I would be incredibly grateful if you could point out any mistakes and possible improvements to my code. I apologise for the length of code, I have removed most of the irrelevant code. Sorry if my formatting isn't very good, this is my first forum post. (posting says access denied so will edit post once posted) Thanks for any help! Actually it is now sending some random characters before the actual data. Also the time between transmissions isn't uniform (1st LED blink, delay, blink blink) (Tx LED) and I can't see why it loops forever? The serial port reader image wont upload so I will try to upload in a reply. P.S. If you see this, DarioG you have helped incredibly without knowing it. I am very grateful for your contribution to these forums! Attachment(s) codeOutput.jpg.zip (8.67 KB) - downloaded 10 times |
|
相关推荐
12个回答
|
|
感谢北方人,不幸的是,我找不到任何人来帮助我,面对“坏”的人…
以上来自于百度翻译 以下为原文 thanks northernLad unfortunately I can't find anyone to help me, facing "bad" people... |
|
|
|
回到代码:如果BuFLEN(在队列中可用)是你传递给“写”函数的字符串长度,会发生什么?你不应该检查一下吗?
以上来自于百度翻译 以下为原文 Back to code: what happens if buflen (available in queue) is > the length of string you're passing to "write" function? shouldn't you check that? |
|
|
|
我不太清楚你的意思是什么?我试图使缓冲区不能长于要发送的字符串,但它没有任何影响。我已经改变了,现在有3个字符串的8个字符发送在一行,输出看起来像这样。(单击每一个字符串以显示它们的顺序后的n按钮)当被捕获到TXT文件时,在ExpRe1[code ]中有3个空格?
以上来自于百度翻译 以下为原文 I'm not fully sure where you mean to check it? I have tried to make it so that the buffer can't be longer than the string to be sent but it hasn't had any affect. void putU1(const uint8_t *buf, int i){ unsigned int bufLen = UART1_TransmitBufferSizeGet(); while (U1STAbits.UTXBF == 1) ; // wait while Tx buffer full if (bufLen > sizeof(char_array)) <--- bufLen = sizeof(char_array); <--- UART1_WriteBuffer(buf, bufLen); } I have changed so that there are now 3 strings of 8 chars sent in a row, and the output looks like this. (i clicked the n button after each string to show their order) When captured to a txt file, there are 3 spaces before example1 [code] ø example1 eightbit maywork? |
|
|
|
嗯,不,sieof返回数组的“静态、整体”大小。
以上来自于百度翻译 以下为原文 Hmm, no, sizeof returns the "static, overall" size of the array. Maybe more something like UART1_WriteBuffer(buf, strlen(buf)); or also UART1_WriteBuffer(buf, min(bufLen,strlen(buf))); |
|
|
|
我已经尝试了这两种方法,它们并没有阻止额外的比特。
以上来自于百度翻译 以下为原文 I have tried both of those and they don't prevent the extra bits still |
|
|
|
在TX寄存器中一次放置一个字符,芯片将处理它放在电线上,这工作于16F1619,然后缓冲此代码的外部:空USATARTUR-PUC(无符号char C){同时(!)!tx1rg= c;}无效UsARTHART(无符号CHAR*s){(*s){UsARTHARTUC(*S);S+++;} }
以上来自于百度翻译 以下为原文 Put one character at a time in the TX register and the chip will handle putting it on the wire, this works for 16F1619, then buffer outside of this code: void USART_putc(unsigned char c) { while(!TXSTAbits.TRMT); TX1REG=c; } void USART_puts(unsigned char *s) { while(*s) { USART_putc(*s); s++; } } |
|
|
|
是的,约翰,但是那些东西不使用队列或FIFO。我想问题在于FIFO…
以上来自于百度翻译 以下为原文 Yep, John, but those things don't use a queue or FIFO. I suppose the issue lies in FIFO... |
|
|
|
好的,同意,这是在FIFO中,我会在GCC中运行FIFO代码并调试缓冲区……只是想知道,你看过这行代码吗?咧嘴笑:
以上来自于百度翻译 以下为原文 Ok, yes, agree, it is in the FIFO, i would run the FIFO code in a gcc and debug the buffer there... Just wondering - have you looked at this line of code?: if (uart1_obj.txTail == (uart1_txByteQ + UART1_CONFIG_TX_BYTEQ_LENGTH)) Maybe your tail gets too long - so subtract 1 from the right side if (uart1_obj.txTail == (uart1_txByteQ + UART1_CONFIG_TX_BYTEQ_LENGTH - 1 )) That would be too easy... grin: but I'm with DarioG, its buffer overrun in your FIFO |
|
|
|
|
|
|
|
|
|
|
|
我正试着逐字逐句地使用你的代码。但根本没有东西在传播
以上来自于百度翻译 以下为原文 I am trying to use your code, word for word. But nothing is transmitting at all |
|
|
|
实际上,它不是“我的”代码。我只是想说明如何使用MCC生成的头文件中的信息,而我的输出似乎表明它对我起作用。我的“代码”将实现相同的块-时间功能,而不使用循环中的巴洛克扭曲逻辑。请参阅脚注。无论如何,因为我只显示了主()和UART放置函数,即使你使用“Word to Word”,我们也没有办法知道你项目中的所有其他东西,包括你的MCC安装。建议:使用MPLABX“包”函数为你的项目创建一个ZIP文件并发布它。有人可以帮你弄清事情的真相。DaveFootnote,“如果不是巴洛克风格,就不要修理它!”--DaveKW7X
以上来自于百度翻译 以下为原文 Actually, it's not "my" code. I just wanted to illustrate how to use the information in the MCC-generated header file, and my output seems to indicate that it works for me. "My" code would implement the same chunk-at-a-time functionality without the baroque, twisted logic inside the loop. See Footnote. Anyhow... Since I only showed main() and the UART put function, even if you use that "word for word," we have no way of knowing everything else in your project, including your MCC setup. Suggestion: Use the MPLABX "package" function to create a zip file for your project and post it. Maybe someone can help you get to the bottom of things. Regards, Dave Footnote: "If it ain't baroque, don't fix it!" ---davekw7x |
|
|
|
只有小组成员才能发言,加入小组>>
5208 浏览 9 评论
2017 浏览 8 评论
1943 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3189 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2244 浏览 5 评论
758浏览 1评论
645浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
563浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
657浏览 0评论
556浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-9 14:22 , Processed in 1.686765 second(s), Total 70, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号