Hello Readers:
I have started this blog to show you Embedded C programming for 8051 family microcontroller using KEIL compiler. The KISS philosophy is used to write this tutorial. What is KISS? Keep It Simple, Stupid!
7. Serial Port Interface
This section teaches you how to send data and receive data from personal computer through serial port.
The program receives as-well as transmits serial data through serial port. When key is pressed data will be sent and otherwise data will be received. The transmitting data will be in R-range-direction [R20 R21 R22 …] format and can be seen on UART#1 window. This is because usually embedded system sends data in certain format so that receiver unit can distinguish it from other data it may receive on same port.
After typing the code, press F7 or click Project->Build Target for building the source code. If there are no typical errors file will build successively and shows zero errors and zero warnings.
Now enter into debug mode by pressing Ctrl+F5 or click Debug->Start/Stop Debug Session menu. Our program is sending character in ‘Rrd’ format [R20 R21 R22 …] to UART #1 continuously. So we want to watch the UART #1 while running this program for receiving values. To get UART #1 tab click View->Serial Windows->UART #1 text.
Run the program by pressing F5 or clicking Debug->Run. You can see the Character ‘R20 R21 …’ on UART #1 tab continuously. The receiving character simulation is not possible as such facility is not provided in this program.
If you generate HEX file of this program, burn it into your target chip’s memory using suitable uploader and connecting chip to PC with the help of serial cable you can watch sending/receiving characters on PC’s Hyper Terminal & on chips LCD module simultaneously. To stop running the program press red ‘x’ mark icon or click Debug->Stop.
...till next post bye-bye & take care.
No comments:
Post a Comment