NPEDUCATIONS, Electronic circuits development, electronics tutorials, microcontroller tutorials and projects, advanced microcontroller (ARM) based tutorials and projects, Embedded c development, Embedded c for ARM cortex M, Intel IoT based projects, IoT projects, CC3200 launch pad projects, MSP430 Launchpad tutorials and projects, Tiva C launch pad tutorials and projects, 8051 tutorials and projects, sensor interfacing with microcontroller tutorials, data communications and networking tutorials, peripheral interfacing with microcontroller, led message scrolling display, arduino based tutorials and projects, intel galileo based tutorials and project, ADC interfacing tutorials, LED Blinking, LCD interfacing, Embedded System tutorials and projects, B.tech projects, M.tech projects, online Embedded C training

8051 Serial port debugging and testing without RS 232 cable


8051 Serial port debugging and testing without RS 232 cable and Microcontroller IC

Make Serial port debugging and testing without any circuit. With the help of keil simulator and any virtual comport software used to test serial port of 8051 microcontroller.

The people (beginners) new to the 8051 microcontroller will face so many problems while dealing with the serial data transfer using serial port in 8051. They will made mistake by preparing the hardware circuit for the serial port using max232 and then they will write program code for serial data transfer by configuring the 8051 serial port. Finally they test the 8051 serial port functionality by changing both the program code and hardware. Generally beginners think that the problem may be in hardware circuit or it may be in the program code, when they don’t have any confidence in the program code or the hardware circuit of 8051 serial port. And they simple waste the time by repeatedly checking the hardware circuit or the program code.

First of all, test your serial port program code by using simulated software like keil and make sure that you don’t have any problem with the program code. By doing so you will have confidence there is no problem with my program code.  Therefore you now only concentrate on the hardware circuit testing. This may reduces the debugging time of your application.

In this tutorial, I have introduced a technique to test the serial port of 8051 microcontroller without building the circuit. You don’t need two computers to test the serial data transfer between them. You don’t need any hardware simulated circuit to be design using simulating software like proteus. You can test your program code for 8051 serial port by using your keil debugger software and virtual serial com port software.

The software tools required for this testing are
1)      Keil microvision C51 (https://www.keil.com/download/product)

Step1: Your program code:
Here I have written the 8051 programming for serial port in assembly language. The code itself demonstrates that it receives a character and again the same character is send via serial port using interrupt method.
ORG 0000h
LJMP Main_Label    ;redirect the CPU control to some other location

ORG 0023h
JNB RI, en    ;Check whether the interrupt is occurred on the reception of character,
              ; if not the interrupt is due to transmission of character
             MOV A, SBUF; read received character into A register.
             CLR RI     ; make RI flag to zero
             MOV SBUF,A ; transfer the received character
en:     nop
             CLR TI     ; make TI flag to zero, TI = 1 --> character is transfered,
                       ;TI = 0 --> transmitter buffer is ready to receive next character
             RETI

             ORG 0100h
Main_Label:  MOV SCON, #50h  ; initialize SCON register with reception enable
             MOV TMOD, #20h  ; initialize TMOD register
             MOV TH1, #0FDh  ; load timer 0 with FD for 9600 bits/sec baud rate.
             MOV IE, #90h
             CLR RI          ; make RI flag to zero
             SETB TR1        ; start timer0
Back:        nop             ; nothing will happen
             SJMP Back       ; infinite loop
                                               

END.




Step2: Install virtual com port software and create two virtual com ports by using it. Here I created com1 and com2 as two virtual com ports as shown in figure1.1.

Before installing the software, check your HyperTerminal program that it will not show any of these virtual com ports created by the virtual com port software except available physical com ports. Laptops don’t have any physical com port available outside; therefore you need a USB to RS232 converter. These USB to RS232 drivers will show the physical comports for your laptop. If USB to RS232 drivers are not installed in your laptop then the HyperTerminal will show only TCP/IP port.

Figure 1.1 Show the virtual serial Port Driver window with two virtual ports

Step3: make the keil debugger as one virtual serial com port by using two commands
            1. Mode com2 9600,0,8,1
2. Assign com2 <sin> sout

The first command is used to configure the virtual serial com port in keil.
The second is used to assign the input and output register for serial data transfer. SIN and SOUT are two virtual registers representing the SBUF register for transmission and reception.
Here I use com2 as virtual com port in keil. But you people can use any of the virtual comports available in your computer or laptop.

First enter into debugger of keil by pressing ctrl+F5 or go the menuà bebug.  The above two commands must be entered one by one in the command window of the keil IDE as shown in the below figure 1.2. You can directly copy the command into the command window or you can type it. While you typing the command you will get help about the command. If you type the first command then press enter and then type the second command as shown in figure 1.2.

Figure 1.2 shows commands are used to make keil simulator work as serial port of 8051.

Step4: open your HyperTerminal with other virtual comport which is not used in the keil debugger. Here I used the com2 for keil debugger; therefore com1 is used to connect the HyperTerminal. Now type the characters on the HyperTerminal will reflected back as shown below figure 1.3.

Figure 1.3 shows that character typed on the HyperTerminal is echoing back due to serial port program is running in keil debugger.






0 comments :

Post a Comment

Thanks for visiting NPEDUCATIONS. We will contact you soon

0 comments :

Post a Comment

Thanks for visiting NPEDUCATIONS. We will contact you soon

If you really like this tutorial, Don't forget to give the comment or please subscribe to the RSS feed by submitting your E-mail or like our Facebook page.
Related Posts Plugin for WordPress, Blogger...

 
Powered by Blogger