??? 11/22/05 14:51 Read: times Msg Score: -1 -1 Off-Topic |
#103997 - Serial Port Configuration |
Hello everyone, first time member, and new to microcontroller programming.
I have a question regarding the 8051/8052 serial port configuration. Now, using the win32 api with createfile, (read|write)file() etc. I can communicate with my dev board that already has some serial i/o routines on the 8051. (paulmon) However, I'm trying to get a better lower level understanding of what is going on during initialization of the serial port. For instance, the call to GetCommState/SetCommState has purpose in setting various parameters like baud rate etc. Ultimately what I'm trying to do is communicate directly with the board without a terminal emulator like Tera Term Pro. I realize that baud rate, stop bits and parity can be set within the terminal emulator options before establishing a connection. Also, I know that those options can be set directly in the SCON SFR in 8051 code. My confusion is since a terminal emulator can set these parameters before hand, I should assume that it is not necessary to do so in code on the 8051? But how are these paramaters being set? Are they transparently set in these cases similar to calling setcommstate in win32? Or these assumptions false? One last thing is that I also would like to set the eofchar field in the DCB struct to some non-printable ascii value so that in 8051 code I can signal to the computer connected on the other side that there is no more data. In other words, if I make a call to readfile() on the computer without a timeout set, then it will block much like a tcp socket. So, my issue is getting around that in the simplest and most elegant way. Now assuming a call to setcommstate() with eofchar set to some val in the DCB is made, I should be able to write to the serial port on the microcontroller side and send that byte and readfile() will finally drop out? (again, assuming I use no timeouts) If this is the case, is there some way to make the code more elegant so that setcommstate can set the eofchar and the code on the 8051 will use that char regardless of what it is? If this is so, I have no idea how to get that information that is sent off from a setcommstate call. I've googled so much over the past couple of days and I can't seem to read anything that addresses my questions. I really appreciate the time taken to read my lengthy post and give me a few pointers (no pun intended) Thank you. |
Topic | Author | Date |
Serial Port Configuration | 01/01/70 00:00 | |
Off-Topic | 01/01/70 00:00 | |
confusion | 01/01/70 00:00 | |
My apologies | 01/01/70 00:00 | |
You've got it!![]() | 01/01/70 00:00 |