完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,我现在正在做有关RS-232信号的项目。对于proteus调试,虚拟终端成功地(从包含的图片)接收来自MCU(PIC18F820)的消息,但是未能向MCU发送任何字符数据。我很困惑,我不知道我在代码中做了什么错误,如果有任何帮助的话,那就太好了!(PS,我是Proteus的新手,我在这个级别的MCU编程经验很少。另外,我在Proteus的示意图上使用了16MHz的外部振荡器,希望这些信息有助于了解新的更新:所以我使用虚拟串口驱动和实时来做一些模拟,我有更多的问题,我不是真的U。我试图从微控制器端发送输入“123456”,它的二进制数据读“00110001 00110010 00110010 00110011 00110100 00110101 00110110”,但是RealTerm边(RealTurn.PNG),它读“01100010 01100100 01100110 01101000 01101010盎司”多少有些数据左移位我能做些什么来解决这个问题(或者是什么引起了这个问题)?此外,在虚拟串口驱动程序(VirtualSerialPosikPr.PNG)上,为什么COM1发送54字节,而COM2可以接收56字节呢?新文件上传:VirtualSerialPortDriver.PNG,Realtim.PNG,T3Y82020UpDeD.Zip
T3Y82020UpDATED.ZIP(4.28 KB)-下载23次 以上来自于百度翻译 以下为原文 Hi, I'm currently doing the project related to RS-232 signal. For the proteus debuging, the virtual terminal successfully(from the picture included)receive message from the mcu(PIC18F8520) but failed to send any char data towards the mcu. I am confused and I have no idea what had I done wrong in the code so it would be great if there is any help! (ps, I'm new to proteus and I have only little experience on mcu programming at this level. Also, I'm using 16Mhz external oscillator on the proteus schemtics, I hope these information helps) ======================================================================= new updates: so im using virtual serial port driver and realterm to do some simulation, and I have more questions I don't really understand...... I'm trying to send the inputs "123456" from the microcontroller side, its binary data reads "00110001 00110010 00110011 00110100 00110101 00110110 " however the RealTerm side(realTerm.PNG), it reads "01100010 01100100 01100110 01101000 01101010 01101100" somewhat the data left shift 1 bit, what can I do to fix this problem(or what caused the problem)? also, on the Virtual serial port driver(VirtualSerialPortDriver.PNG), why is the COM1 sending 54 bytes while COM2 can receive 56 bytes? new files uploaded: VirtualSerialPortDriver.PNG, realTerm.PNG, t3_8520_updated.zip Attached Image(s) Attachment(s) t3_8520.zip (4.04 KB) - downloaded 28 times t3_8520_updated.zip (4.28 KB) - downloaded 23 times |
|
相关推荐
4个回答
|
|
您误用C头文件。您不应该在头文件中有可执行代码,只是定义。这不是您的直接问题,但它会使您在轨道上进一步陷入各种悲痛。(在组织代码文件I中描述构建多文件C项目的正确方法。NC和C++(忽略C++特定的位))http://www. gMeDEV.NET/PA...文件C和C-R1798。主要问题可能是你的RCSTA1 SETIN GRCSTA1=0B10011000;你已经设置了Addie位。不要这样做,它抑制接收直到一个特殊的地址字节被接收。LSO,您正在设置TXEY和RCIE。这将导致您在设置PEIE和GIE的时候出现问题,因为PIC将尝试服务USAT中断,但是您没有中断服务例程。您的代码正在轮询状态标志,以查看USAT何时就绪,从而不需要设置XXY标志。
以上来自于百度翻译 以下为原文 You are misusing C header files. You should NEVER have executable code in a header file, just definitions. That is not your immediate problem, but it's going to cause you all sorts of grief further down the track. (The correct way to build a multi-file C project is described at Organizing Code Files in C and C++ (Ignore the C++ specific bits) ) http://www.gamedev.net/pa...files-in-c-and-c-r1798 the main problem is likely to be your RCSTA1 setting RCSTA1 = 0b10011000; You have set the ADDEN bit. Don't do that, it supppresses reception until a special address byte is received. Try: RCSTA1 = 0b10010000; Also, you are setting TXIE and RCIE. That will cause you problems the moment you also set PEIE and GIE, as the PIC will try to service USART interrupts, but you do not have an interrupt service routine. Your code is polling the status flags to see when the USART is ready so you do NOT need the xxIE flags to be set. |
|
|
|
我正在做更多的模拟,并与发送器部分的问题……也是因为我弄乱了TX寄存器呢?(抱歉,我真的是新的注册级别的编码),我也做了PEI和GEE寄存器初始化,因为(我想)数据表是这样说的(我遵循了第18.2.1和18.2.2章中的步骤),我应该赞扬这两个函数吗?PS。非常感谢C头文件的注释。部分。
以上来自于百度翻译 以下为原文 I'm doing some more simulation and meet issues with the transmitter part as well....is that because I messed up the TX register too?(sorry, I'm really new to register level of coding) Also, I did the PEIE and GIE registers initialization because (I thought) the datasheet said so(I was following the steps in chapter 18.2.1 and 18.2.2), should I commended those two functions. PS. really appreciate the comments on the C header file part. |
|
|
|
不知道,因为你没有提到什么“遇到问题”的意思。总是,如果你有一个问题,解释你期望发生什么,发生了什么,足够详细地让我们看看你做了什么。我想你错过了“如果中断是希望……”的一部分评论。如果中断启用,然后,当设备XXE标志被设置时,你的PIC会跳转到中断服务程序。如果你没有中断服务程序(你不这样做),那么你的代码就会崩溃。
以上来自于百度翻译 以下为原文 Don't know, because you did not mention what "meet issues" means. Always, if you have a problem, explain what you expected to happen, and what did happen, in enough detail for us to see what you did. I think you missed the "If interrupts are desired..." part of the comment. If interrupts are enabled, then your PIC will jump off to an interrupt service routine when the devices xxIE flag is set. If you don't have an interrupt service routine (which you don't), then your code will crash. |
|
|
|
简单地说,是的,不能使GIE(它应该被清除-设置为零(0))用于您当前的代码。
以上来自于百度翻译 以下为原文 Simply put, yes DO NOT enable the GIE (it should be cleared - set to zero (0)) for your present code. |
|
|
|
只有小组成员才能发言,加入小组>>
5262 浏览 9 评论
2044 浏览 8 评论
1960 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3221 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2271 浏览 5 评论
799浏览 1评论
692浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
626浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
690浏览 0评论
589浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-2 03:42 , Processed in 1.257309 second(s), Total 84, Slave 68 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号