完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
大家好!我对C编程非常陌生。我正在使用一个PvDEM网2板的WebVeDemo应用程序来学习Prpules。我想调用UART的线程数据打印到我的网页。我正在使用MPLAB X IDE V4.5与C18编译器和PIC18F97 J60微控制器。我试图调用UART的数据,但没有成功。我的网页显示“!所以我想今天不是我的日子。我在某个地方发现,串行RS232端口的线程数据自动出现在PIC中的UART中,这是由演示应用程序中的演示代码C处理的,所以我想我只是不知道如何正确调用它。有人能帮助我,我应该调用什么来打印从UART的线程数据?我附上演示UART文件。
UART.C.txt(10 KB)-下载54次 以上来自于百度翻译 以下为原文 Hello guys! I'am very new to C programming. I'am using a webvend demo app with a PICDEM net 2 board for learning porpouses. I want to call readed data from the UART to print to my webpage. I'am using an MPLAB X ide v4.5 with C18 compiler and a PIC18F97J60 microcontroller. I tried to call the data from the UART with no success. My webpage shows " !DEF " so i guess its not my day. :D I readed somewhere that the readed data from Serial Rs232 port is automatically appear in the UART within the PIC which is handled by the demo.c code in the demo app , so i guess i just don't know how to call it properly. Can anyone help me what should i call to print the readed data from the UART? I attached the demo UART files. Attachment(s) UAR2TCPBridge.C.txt (13.97 KB) - downloaded 87 times UART.C.txt (10.00 KB) - downloaded 54 times |
|
相关推荐
14个回答
|
|
|
从你的描述中很难理解你想说什么,你的问题是什么。有了你的描述,阅读你的源文件和寻找……并不是很有吸引力。什么?对于我来说,不清楚您是否收到UART的问题,或者发送到UART,或者更可能在您项目的所有不同部分的组合中。还不清楚你已经调试了你的问题。我认为你必须把你的问题分解成更小的部分——主要是为了你自己能够分析你的问题的根源,并且提供更详细的信息,以防你仍然需要帮助。我现在的印象。关于你开始学习C和PIC的挑战太大了。这可能是HTTP://www. McCHIP.COM/FUMMS/M108255-P2.ASPX的继续。
以上来自于百度翻译 以下为原文 It's hard to follow from your description what you want to say and what your problem is. With your description it is not really appealing to read your source files and spot for ... what ? For me it's not clear whether you have a problem receiving from UART, or sending to the UART, or more likely in the combination of all the different parts of your project. It's also not clear what you did already to debug your problem. I think you have to break down your problem into smaller parts,- primarily for yourself to be able to analyze the source of your problem, and also to provide more detailed information in case you then still need help. My current impression is that you started your learning of C and PIC with a too challenging application. May be this is the continuation of http://www.microchip.com/forums/m1038295-p2.aspx |
|
|
|
|
|
是的,也许太过分了。我用Android的一个叫做SoloLearn的应用程序启动它。我在Java编程几个月,但我不得不改变C,它不一样不幸。我必须以这种语言为生。所以我必须从UART中读取。这是我真的不知道怎么做的。我尝试了读卡机与PC机,它很容易,但我必须处理它与我自己的程序。我认为WebvEnter是最容易的,因为它的网页。
以上来自于百度翻译 以下为原文 Yeah , maybe its too challanging. I started it with an app called SoloLearn , for android. I was programming in java a few months but i had to change to C and its not the same unfortunatelly. I must learn this language for a living. So the thing is i have to READ from the UART. And that is what i don't really know how to. I tried a card reader with PC and its easy but i have to handle it with my own program. And i think the webvend was the easyest because of its webpage. |
|
|
|
|
|
事实上,读卡器将RS232中的数据发送给我的PIC UART,它由演示应用程序处理。我必须从UART中读取这些数据并将其打印到网页上。这就是全部。我知道如何打印它,这样我就不知道我应该从UART中读取什么。
以上来自于百度翻译 以下为原文 So in fact the card reader is send a data in RS232 to my PIC UART which is handled by the demo app. I have to read that data from UART and print it to the webpage. Thats all. I know how to print it and such i just dont know what should i read from the uart. |
|
|
|
|
|
是的,仅此而已,但这已经太多了:我猜:-你正在使用复杂的示例代码,但可能还不了解你的PIC UART的基础知识。在您的发布代码(桥接)中,TCP和UART在状态机中混合。你怎么知道它在哪里失败了?正如你所说的,你需要打破你的任务/问题,否则你就失去了。这没有任何意义。也许你应该从更精确的描述开始。除了你之外,还有谁应该知道你应该从UART中读到什么?你有没有检查过,你是否收到任何东西?你知道怎么做吗?你是否遵循了用PC代替卡片阅读器发送你的第一个测试数据的建议?
以上来自于百度翻译 以下为原文 Yes, that's all, but that's already too much I guess :-) You are using complex example code but probably did not yet understand the basics of your PIC UART. In your posted code (bridge) TCP and UART is intermixed in the state machine. How do you know whether and where it fails ? As said, you need to break down your tasks / problems, or you are lost. This does not make any sense. May be you should start with being more precise in your descriptions. Who else but you should know what you should read from the uart ? Did you check at all, whether you are receiving anything ? Do you know how to do this ? Did you follow the advice to send your first test data with the PC instead of your card reader ? |
|
|
|
|
|
对不起,因为我的英语,说明是错误的。我想说,我知道我应该读什么,我用PC测试了阅读器,我知道它发送一个40位长的十进制数据,并且我能够用PC和默认的读卡器程序监控它。我不知道它是什么地方保存在UART的照片。事实上,我可以用程序来操纵数据,我可以给读卡器写数据,我可以把修改后的数据修改为7位长等。在这种情况下,阅读器通过RS232发送一个7位长的数据,比如0001110,到PIC,并且实际上存储和处理了数据。EUART。但我不知道在哪里,我不知道如何调用项目中保存的数据在一个名为:CustomHTTPapp .c的不同文件夹中,将其打印到网页上。我希望它能有所澄清。
以上来自于百度翻译 以下为原文 Sorry the description is false because of my English. I wanted to say that i do know what should i read , i tested the reader with the PC , i know it sends a decimal data which is 40 bit long , and iam able to monitor it with a PC and with a default card reader program. I dont know where it is saved inside the UART in the PIC. Actually i can manipulate the data with the program , iam able to write to the card reader , i can modify the sended data to be just 7 bit long or etc. In this case , the reader sends for example a 7 bit long data like 0001110 , to the PIC via RS232 and that data in fact is stored and handled in the UART. But i dont know where , and i dont know how to call that saved data inside the project in a different folder called : CustomHTTPapp.C to print it to the webpage. I hope it clears something. |
|
|
|
|
|
|
|
|
|
|
|
不,不是真的。也许它表明你可能缺乏对它是如何工作的一些基本的理解。我仍然不确定,我不认为英语是这里的问题。你解释了你用电脑和阅读器做了什么,但是这不是你的问题的一部分,在你的最后一个帖子里没有新的信息。这又增加了混乱。我不知道我该向你推荐什么。你只是在为自己学习,对吧?或者你的申请背景是什么?这个论坛可能不是教你C编程的好地方,或者从一开始就教你PIC和嵌入式系统的基础知识。如果你对UART有问题,并且理解UART外设(硬件/硅)和你必须编写的固件(或者使用和修改现有固件)之间的区别,那么你应该尝试插入一个新的章节并学习(阅读和练习),然后再继续。更复杂的应用程序。我在你的另一篇文章中,开始在你的PC /终端程序之间做一些UART通信,并尝试与你的PIC通信。忘记读卡器,现在忘记TCP/Web。一旦你知道UART是如何工作的,你就可以返回更复杂的项目。
以上来自于百度翻译 以下为原文 No, not really. May be it makes clear that you probably lack some basic understanding of how it works. I'm still not sure and I don't think that English is the problem here. You explain what you have done with the PC and Reader, but that is not part of your problem,- there is no new information in your last post. This again just adds confusion. I have no idea what I should recommend you. You are just learning for yourself, right ? Or what is the background of your application ? The Forum probably is not the right place to teach you C-programming or to teach you the basics of PIC and embedded systems from the beginning. If you have problems with the UART and understanding the difference between the UART peripheral (hardware/silicon) and the firmware you have to write (or use and modifiy existing firmware) then you should try to insert a new chapter and learn (read and exercise) about that before you continue your more complex application. As I wrote in your other post, start to do some UART communication between your PC / terminal program and try to communicate with your PIC. Forget the card reader and forget the TCP / Web for now. Once you know how the UART works you can return to the more complex project. |
|
|
|
|
|
如果不是这样的话,我怎么理解UART编程?有一个演示UART程序,它写给想学习它的人。不是吗?好吧,我知道我必须学习和掌握C之前,我写我自己的节目,当然。我目前正在网上阅读C书,但这让我很困惑。我试图自己学习,是的,但如果不是,演示程序是这样做的,比我不知道什么。对于UART,像硬件一样,我理解它的结构,以及它是如何工作的。我不希望这些人在C或嵌入式系统中教我。据我所知,在C语言或任何其他语言中,您可以在程序中的寄存器或其他地方保存传入的数据。在我的例子中,我能够向Web页面打印来自LCD的一些数据,并且可以从网页中的自定义输入将数据保存到ROM中的AppCOnFIG。所以我想UART的数据也是一样的。我无法理解我在文章中提到的两个文件。所以我唯一的问题是在这些文件中,输入的数据保存在某处或者只是处理并扔掉?我理解你,你不想教我,也不可能在网上。对不起,如果我不能正确地写我的问题。
以上来自于百度翻译 以下为原文 How can i understand the UART programming if not like this? There is a demo UART program , its written to the peoples who wants to learn it. Isn't it? Okay i know i have to learn and master in C before i write my own program of course. I'am currently reading a book from C in the internet but thats just confusing me. I trying to learn by myself yes , but if not the demo programs are the way for this, than i dont know what. For the UART like a hardware i understand the structure , and how it works. And i dont want the forumers to teach me in C or in embedded systems. As far as i know in the C or any other language you can save an incoming data in registers or somewhere else in the program. In my case i'am able to print to the web page some data from the LCD and i can save data to the appconfig in ROM from a custom imput from webpage. So i guess its the same with the UART's data. And i can't understand that two files that i mentioned in my post. So my only question is in these files , the incoming data saved somewhere or just process it and thrown away? I understand you , you don't want to teach me and probably can't in the internet. So sorry if i can't write my issue properly. |
|
|
|
|
|
不,你以前不需要主人。我只是假设你能在C中编程,甚至更多,你必须能够“读”它,特别是如果你想开始用示例代码学习的时候。自学和做中学也是一个很好的方法。你只是需要一些开始,从简单的…更先进。什么是“简单”取决于你的开始知识。最重要的是(没有人能回答你),你想用你当前的“项目”来实现什么。即使你可能回答你的主要目标是“学习”,那么下一个问题可能是,接下来你想用你的新K来做什么。现有知识。(当你写信说你从Android / Java编程切换到PIC嵌入式时,我很惊讶。)我有时也想知道一些技术,但我知道我只想得到粗略的理解,我不打算“使用”它,我不需要关心细节。然后我还有其他的“项目”。TS“我想避免深入细节,因为我只是想使用一些技术,但它会花费我太多的时间来关注细节。例如,对于我来说,PIC USB堆栈可能与UART代码类似。但是还有第三类,我想知道所有的细节,因为我很好奇,或者因为我不能做我的工作。例如,在嵌入式项目中,经常需要通过UART、I2C或SPI进行通信,所以在学习时,深入到这里是很有价值的。因为我不知道你要去哪里,所以很难推荐一些东西。如果你的硬件从读卡器到网页都能工作,你可以把精力集中在一些令人兴奋的应用程序上。你不想知道更多关于RS232、UART或TCP的细节,因为这会分散你的注意力,或者你没有时间。如果你从很远的地方看它,那么这是真的。但显然你有一个问题,所以当它进入细节时是不一样的。所以我们回到“我的”主要问题,向你推荐什么。从我所看到的,我想你有必要了解更多关于你的UART的细节(只是为了学习)。在这种情况下,您需要了解UART.C文件。但是你也可以考虑UART.C来成为一个库,它允许你从UART中抽象出来,你只需要知道这个文件/库提供的函数。(假设这个代码中没有bug,什么是有挑战性的)。你的UAR2TCPBase.C利用这个低级UART。C已经混合了UART、中断、缓冲器、状态机、TCP的概念。这是比较困难的,事实上,我自己不想分析和调试它给你或教给你,它需要太多的时间(用尽我的时间现在这个职位),不知道你真正要做什么,你的问题是哪里。这就是为什么我认为THA。你从一个太复杂的例子开始。UART2TCPBReal.c文件显示了很多编辑和注释部分等。所以我不太相信它是经过验证的代码,它只是按原样工作。如果这是唯一的问题,那么答案是,假设文件是一个桥。一个UART和一个TCP连接。(连接的2个方面)的概念是,例如UART的数据保存在RAM中的缓冲区中。查看文件中的评论,例如VuARTrxFIFO,RXHeadPtr,RXTailPtr。该实现使用循环缓冲区(因此,头和尾),并且它也似乎使用阴影缓冲。因此,您的问题的答案是,将传入的数据保存在缓冲区中。如果文件按预期使用(不需要更多代码就不可能看到),这是我不想看到的。EE),然后数据是“刚刚处理,并再次扔掉”,正如你写的。还有一些其他代码必须确保正确的初始化并保持状态机(UART2TCPBRIDGETASK函数)运行。
以上来自于百度翻译 以下为原文 No, you don't need a master before. I just assume that you are able to program in C, and even more, you must be able to "read" it, especially if you would like to start learning with sample code. Learning by yourself and learning by doing is also a good method. You just need something to start with, from simple ... to more advanced. What is "simple" depends on your starting knowledge. The most important is (and nobody can answer that for you), what you want to achieve with your current "project". Even if you might answer that your major goal is "learning", then the next question could be, what you want to to next with your new knowledge. (I was astonished when you wrote that you switched from Android/Java programming to PIC embedded.) I sometimes also would like to know about some technology, but I know I only want to get a rough understanding, I'm not going to "use" it, I do not need to care about details. Then I have other "projects" where I would like to avoid having to dive into the details, because I just want to use some technology, but it would take me just too much time to care about the details. E.g. for me the PIC USB stack may be similar to your UART code. But then there is a third category, where I want to know all the details, either because I'm curious or because otherwise I cannot do my work. E.g. knowledge about communication via UART, i2C or SPI is very often required in embedded projects, so it is worth to go more into the depth here when learning. Since I do not know where you are going, it is difficult to recommend something. Possibly you are happy if you all your hardware from Card Reader to Web Page just works and you can focus on some exciting application built on that. And you don't want to know more details about RS232, UART or TCP, because that would distract you from the focus or you just don't have the time. If you are looking at it from a far enough distance, then this is true. But apparently you have a problem, so it is not the same when it goes into details. So we are back to "my" main problem, what to recommend to you. From what I see, I would guess it makes sense that you go into more details about your UART (just for learning). In this case you need to understand your uart.c file. But you could also consider uart.c to to be a library, which allows you to abstract from the UART and you only have to know about the functions provided by this file/library. (this assumes that there are no bugs in this code, what is challenging). Your UAR2TCPBridge.c makes use of this low-level uart.c. It already mixes concepts of UART, Interrupts, buffers, state machines, TCP. This is more difficult and actually I myself would not like to analyze and possibly debug that for you or teach it to you, it just takes too much time (used up my time for this post now), and without knowing what you really are going to do and where your problem is. That's the reason why I think that you started with a too complex example. Also the UART2TCPBride.c file shows a LOT of editing and commenting out parts etc. So I'm not very confident that it's proven code, which just works as it is. If that's really the only question, then the answer is, that the file is assumed to make a bridge between an UART and a TCP connection. (2 sides of your connection) The concept is that the data from e.g. the UART is saved in a buffer in RAM. See the comments in the file for e.g. vUARTRXFIFO, RXHeadPtr, RXTailPtr. The implementation uses a circular buffer (therefore Head and Tail) and it seem also to use shadow buffering. So the answer to your question is, that your incoming data is saved in the buffer. If the file is used as intended (which is impossible to see without even more code, which I do not want to see), then the data is "just processed and again thrown away" as you wrote. Still some other code would have to ensure proper initialization and keep the state machine (UART2TCPBridgeTask function) running. |
|
|
|
|
|
我对你印象深刻。你是一个非常善良的人。对于你的问题,是的,我想谈谈这个项目的细节,我必须不幸地理解这些事情。如果我不需要,我就不会尝试。我从老板那里得到了很少的帮助,比如:“嘿,这里有一个PIC学习编程,为我做那件事。”这是基本出发点。我对他说:“Hm.。好吧,如果你愿意的话,我会努力学习的。好的,随着时间的推移,现在我必须为他写一个程序,它必须能够通过串行RS232与读卡器和PIC通信,因为这是我们所拥有的。它必须很快,很小。有五张卡,我必须阅读和处理它的C代码,并把它们分开,并为每一张卡片做一个页面。所以我知道我必须做什么,我约斯特现在还不知道到底是怎么回事。我在这件事情的UART部分,现在我必须学会。在我的项目的另一部分,我必须编写一个代码来读取UART数据并处理它。^ ^
以上来自于百度翻译 以下为原文 Iam very impressed by you. You are a very kind guy. For your questions , yes i want to go to the details in this project , i have to understand these things unfortunatelly. If i dont have to, i wouldnt try. I got a very few help from my boss like , " Hey here is a pic learn programming it and do that and that for me". So thats the basic starting point. I say that to him , " Hm.. okay if you want it to , i will try to learn it". Okay and that goes deeper with time , now i have to write a program for him , and it have to be able to communicate beetween a card reader and a pic via Serial rs232 , because that is we have. It has to be fast , small. There are like five card which i have to read and process it in the C code , and separate these from each other and make a page for every card. So i know what i have to do , i jost don't know exactly how right now. Iam at the UART part of this whole thing and i have to learn that now. And in the other part of my project , i have to write a code which is read the UART datas and process it. ^^ |
|
|
|
|
|
在解释两个提供的源文件之间的差异时,我错了。我认为你在你的项目中使用这两个项目。就我所见,UART.C中没有一个函数用于UAR2TCPrBug.CimSTATE UAR2TCP桥。C包含所有必需的UART代码,并直接访问外围寄存器。它还包含中断功能。因此UART.C对您的项目可能是无用的(对于UART基础知识来说更容易理解)。
以上来自于百度翻译 以下为原文 I was wrong when explaining the difference between your two provided source files. I thought that your were using both in your project. As far as I can see, none of the functions in uart.c is used in UAR2TCPBridge.c Instead UAR2TCPBridge.c contains all the necessary UART code and accesses the peripheral registers directly. It also contains the interrupt functions. So uart.c is likely useless for your project (while is easier to understand for learning UART basics). |
|
|
|
|
|
这是随机博士(弗拉迪米尔)你的另一个身份吗?http://www. McCHIP.COM/FUMMS/M1041863.ASPXhttp://www. McCHIP.COM/FUMMS/M1041457.ASPX
以上来自于百度翻译 以下为原文 Is this Dr. Random (Vladimir) another identity of you ? http://www.microchip.com/forums/m1041863.aspx http://www.microchip.com/forums/m1041457.aspx |
|
|
|
|
|
坚持一个线程,而不是3个相同的问题。它会导致混乱,因为你会得到答案在不同的线程。
以上来自于百度翻译 以下为原文 Stick to one thread, not 3 with the same question. It causes confusion as you will get answers in different threads. |
|
|
|
|
|
YAP,我无法登录这个帐户,我创建了另一个,当我上传第一个问题,它没有出现,但显示了一个错误,而是我写了另一个在那个帐户,然后这两个问题出现在论坛不知何故。昨天,当我再次尝试这个账户时,我登录了。这是我的运气。
以上来自于百度翻译 以下为原文 Yap , i was unable to log into this account , i created another one and when i upload the first question it didn't appear but showed me an error instead so i write an other one on that account and after that both of the question appeared in the forum somehow. And yesterday when i try this account again , i was able to log in. Thats my luck. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
473 浏览 0 评论
5793 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1124浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1095浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
873浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 04:49 , Processed in 0.866647 second(s), Total 97, Slave 81 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
403