lab mannual 8051 new
TRANSCRIPT
Developed as Learning Material for Training of Students under TEQIP
User’s Guide For
8051 Development Board- DB - 51
Designed & Developed In-house
by
P.T.Karule Assistant Professor & HoD
A.P.Deshpande Lecturer
Department of Electronics & Communication Engineering
Yeshwantrao Chavan College of Engineering, Nagpur - 441 110
2007-2008
YCCE/ECE/MANUAL-8051/PTK/APD 2
Table of Contents
1. Introduction 2. Getting started
2.1 Unpacking 2.2 On the board 2.3 Power Supply Requirement 2.4 Computer requirement
3. Installing Software 3.1. Installing RIDE – assembler
3.1.1. About RIDE Assembler (FREE software available on web) 3.1.2. RKit51+XA Installations and Invocation 3.1.3. Help Documents 3.1.4. Reference Manuals 3.1.5. Support
3.2. Installing Flash Magic – In-System Programmer 3.2.1. About Flash Magic 3.2.2. Installation of Flash Magic 3.2.3. Support
4. How to use DB-51, assembler and ISP 4.1. Connecting the board to PC 4.2. How to use assembler - RIDE (software) 4.3. How to use – Flash Magic In-system Programmer (software) 4.4. How to down load program on the kit (DB-51)
5. Port pins used for connection of devices 5.1.) LCD (16 character X 2 Line) 5.2.) Tele keypad (4 x 3) 5.3.) Common anode seven segment display (One digit) 5.4.) LED 5.5.) I2C bus 5.6.) Stepper Motor Connector (J9) 5.7.) RS232 bus: (connector D9F) 5.8.) DC supply available for stepper motor
6. Sample test programs 6.1. Program #1: 8 bit LCD program to display "Dept. of ECE" in first line & "YCCE8051/PTK/APD" in second line 6.2. Program #2: Blink LED connected to P0.4
7. Serial data transfer via RS 232 port 7.1. Using HyperTerminal 7.2. Baud rate setting of microcontroller
8. Hardware description 8.1. DB – 51 kit on board Components 8.2. Layout Map of components & connectors on the board 8.3. Circuit diagram
9. Appendix
YCCE/ECE/MANUAL-8051/PTK/APD 3
1. Introduction The 8051 based single board development system (DB – 51) support 8051 family
microcontroller. The software supplied with this kit is having Assembler and In System
Programmer (ISP). Due to this software assembling and programming Flash program
memory becomes very easy. The user for developing real time projects can use this
mini board as a development platform. User can design, build and test any 8051 based
application / project with the help of this development board quickly.
This system is useful for students, teachers, professionals and hobbyist. Student
can apply his theoretical knowledge to develop some project and test it with the help of
this system. Teacher can set new experiments for students based on 8051
microcontroller interfacing with Keypad (3X4), seven-segment display, LED, Switches,
relay, LCD, RTC, E2PROM, I2C bus and RS232 bus. Teacher can also set experiments
based on timer application (as timer / event counter) and serial communication (data
transfer from kit to PC and PC to kit). The professional can develop, test and debug his
project. Also hobbyist can use this board to design and develop their own applications.
This board (DB-51) is provided with PHILIPS P89v51RD2 microcontroller.
YCCE/ECE/MANUAL-8051/PTK/APD 4
2. Getting Started 2.1 Unpacking You will find following items in the package.
DB – 51 kit with LCD (16 character X 2 line)
Serial communication cable
Transformer (9-0-9) with power cable
CD-ROM containing software and data sheets
RIDE assembler
FLASH MAGIC (ISP)
2.2 On the board On DB – 51 board you will find
Microcontroller PHILIPS P89v51RD2 (8051 family)
RTC DS1307 (64 x 8 Serial Real-Time Clock)
EEPROM 24C32 (Two wire serial EEPROM)
MAX232
One Seven Segment Display
One LED
ISP switch
RESET switch
IC 7447 (BCD to 7seg driver)
ULN 2803 (Stepper motor driver)
Connector for RS232, LCD, I/O ports & power supply
2.3 Power Supply Requirement : Power supply of 230V AC for step down transformer 9-0-9. The onboard rectifier
convert it to +9V and –9V which is regulated by 7805 to provide 5V DC to all
components on the board. Transformer output is connected to J8 connector (3 PIN) on
a kit.
2.4 Computer requirement :
• An 80486 processor (or better) running a 32-bit Microsoft operating system:
• Operating System Microsoft 95/98/ME/NT/2000/XP
• Memory Required 16 megabyte (MB) of RAM
YCCE/ECE/MANUAL-8051/PTK/APD 5
• A hard-disk drive with 30 megabytes of free space. The actual space required
depends on the options you select. Additional space is needed for your source-
code files and the executable files created from them.
• COM port (RS232)
• Mouse
3. Installing Software: Copy the folder (ycce_kit) from CD to your computer Ycce_kit consist of RIDE assembler, FLASH MAGIC ISP software, sample programs and data sheets
3.1. Installing RIDE - assembler
3.1.1. About RIDE Assembler (FREE software available on web) RKit51+XA is a set of tools that are smoothly integrated into a single environment
called RIDE.
Using this unique Integrated Development Environment (IDE) you can:
• Create and edit your programs, written in either assembly or C language.
• Run the compilers, linkers and debugger tools.
• Maintaining a dual project “80C51 – XA”, switching at any time from a 51-
derivative to an XA-derivative, with just one click!
3.1.2. RKit51+XA Installations and Invocation
The « RKit51+XA-Installation » program (INSTALL.EXE) installs all the necessary files
and correctly configures the environment for running the interface and the development
tools. Please close all other active application programs prior to installation.
To run the installation program :
1. Select SW_8051 >> ride-new >> EVAL >> INSTALL.EXE
2 Follow the instructions in the installation window.
3 After restarting the computer select Start | Programs | Raisonanace Kit 6.1 | Ride IDE
YCCE/ECE/MANUAL-8051/PTK/APD 6
3.1.3. Help Documents
Extensive on-line help is available. You can access via the Help command in main screen or,
for context-sensitive help, you can press F1 from a specific window with a highlighted item.
3.1.4. Reference Manuals The Reference Manuals are available on the CD-ROM in *.pdf format and you can read
them with Acrobat Reader. Acrobat Reader is not available on the CD, but you can
download the latest version without charge from the Adobe web site :
http://www.adobe.com/acrobat
3.1.5. Support For any question related to the RKit51+XA, you may send an email to
You can also download the latest version of RC-51 and RC-XA C compilers from our
WEB sites : http://www.raisonance.com or http://www.raisonance.fr
3.2. Installing Flash Magic – In-System Programmer (FREE software available on website of Embedded Systems Academy )
YCCE/ECE/MANUAL-8051/PTK/APD 7
3.2.1. About Flash Magic: NXP Semiconductors produce a range of Microcontrollers that feature both on-chip
Flash memory and the ability to be reprogrammed using In-System Programming
technology.
Flash Magic is Windows software from the Embedded Systems Academy that allows
easy access to all the ISP features provided by the devices. These features include:
• Erasing the Flash memory (individual blocks or the whole device)
• Programming the Flash memory
• Modifying the Boot Vector and Status Byte
• Reading Flash memory
• Performing a blank check on a section of Flash memory
• Reading the signature bytes
• Reading and writing the security bits
• Direct load of a new baud rate (high speed communications)
• Sending commands to place device in Boot loader mode
3.2.2. Installation of Flash Magic: To run the installation program:
1. Select SW_8051 --- Flash Magic Setup ----double click
2. Follow the instructions in the installation window.
3. After restarting the computer select Start | Programs | Flash Magic | Flash Magic
3.2.3. Support For support you can visit web sites
[email protected] www.esacademy.com/software/flashmagic
YCCE/ECE/MANUAL-8051/PTK/APD 8
4. How to use DB-51, assembler and ISP 4.1. Connecting the board to PC :
The serial communication cable supplied with the board should be used to
connect the RS 232 port of board to the COM_1 port of the PC.
Insert the transformer output connector (3pin) into the onboard power socket.
Plug the power adaptor into 230V AC mains outlet
The DB – 51 is now ready to turn ON.
4.2. How to use assembler - RIDE (software):
You can create a shortcut of RIDE IDE on desktop.
To open assembler:
Click on >>Start >> Programs >> Raisonanace Kit 6.1 >> Ride IDE or click icon
RIDE IDE on desktop (It will open a window of RIDE assembler)
Click on file >> New >> assembler files >> untitled.a51>>
Type assembly language program. First line of your program will be always
$MOD51 and last line will be END, then save as xyz.a51
YCCE/ECE/MANUAL-8051/PTK/APD 9
Click on file >> Project>> Translate xyz.a51 >> check for errors in the window
below.
Rectify the errors and then Click on file >> Project>> Build all After assembling xyz.hex file is created.
To execute the program AND check the result Click on >> debug >> start xyz.aof
To view the contents of port, registers
Click on >> view >> hardware peripherals >> P1
Click on >> view >> Main registers
Click on >> view >> Data dump >> Data View
YCCE/ECE/MANUAL-8051/PTK/APD 10
To execute program in single stepping mode >> press F7 and see the result
After execution Click on >> debug >> terminate
YCCE/ECE/MANUAL-8051/PTK/APD 11
4.3. How to use – Flash Magic In-system Programmer (software):
Flash Magic ISP is used to down load hex file of program into flash memory of
89v51RD2. Ensure that serial cable is connected to COM port
Click on Flash Magic icon
>>Options>>adv option>>Hardware>>unselect use DTR
Follow the 5 steps given below:
Follow Step 1, Step 2: Select Erase Block, Step 3 to Step 5
Select the settings as given in the above window.
4.4. How to down load program on the kit (DB-51) Press step5: start button
Press both the switches present on kit simultaneously RESET and ISP Then first release RESET and then release ISP switch.
The HEX file is transferred to microcontroller (To run program press RESET)
YCCE/ECE/MANUAL-8051/PTK/APD 12
5. Port pins used for connection of devices 5.1.) LCD (16 character X 2 Line):
5.2.) Tele keypad (4 x 3):
Rows Columns R1 P1.0 C1 P1.4 R2 P1.1 C2 P1.5 R3 P1.2 C3 P1.6 R4 P1.3
Signal I/O pin
RS P0.5
R/W P0.6
EN P0.7
D0 – D7 (8 bit) P2.0 – P2.7
Row – Col Key No. R1 – C1 1 R1 – C2 2 R1 – C3 3 R2 – C1 4 R2 – C2 5 R2 – C3 6 R3 – C1 7 R3 – C2 8 R3 – C3 9 R4 – C1 * R4 – C2 0 R4 – C3 #
YCCE/ECE/MANUAL-8051/PTK/APD 13
5.3.) Common anode seven segment display (One digit)
Signal of IC 7447 (BCD to 7 seg code converter)
I/O pin
D C B A P0.3 –P0.0
P0.3 P0.2 P0.1 P0.0
D C B A 5.4.) LED: 5.5.) I2C bus: 5.6.) Stepper Motor Connector (J9): 5.7.) RS232 bus: (connector D9F) 5.8.) DC supply available for stepper motor
Device I/O pin LEDA (red) P0.4
Signal I/O pin SCL P3.2 SDA P3.3
J9 (Connector) I/O pin 1 12V 2 P3.7 3 P3.6 4 P3.5 5 P3.4
Signal I/O pin T X D P3.1 R X D P3.0
Connector Voltage J10 12V J11 5V
YCCE/ECE/MANUAL-8051/PTK/APD 14
6. Sample test programs Program #1
; 8 bit LCD program to display "Dept. of ECE" in first line ; & "YCCE8051/PTK/APD" in second line $MOD51 LCD_PORT EQU P2 LCD_EN EQU P0.7 LCD_RW EQU P0.6 LCD_RS EQU P0.5 ORG 0000H
MOV SP,#40H ; Initialise stack pointer ACALL LCD_INIT ; Initialise LCD
MOV DPTR,#0100H ; Base address of Look up table MOV R5,#00H ; Index
L3: MOV A,R5 ; Display First Line MOVC A,@A+DPTR CJNE A,#24H,L10 MOV A,#0C0H ; DD RAM Address (Second Line) ACALL COMM ; Display Second Line INC R5
L12: MOV A,R5 MOVC A,@A+DPTR CJNE A,#24H,L11
L13: SJMP L13 L10: ACALL DISP ; Subroutine to send data to DR
INC R5 SJMP L3
L11: ACALL DISP INC R5 SJMP L11
LCD_INIT: ACALL delay_100ms ; Delay of 100msec
MOV A,#38H ; Function set instruction is given 3 times ACALL COMM ; Subroutine to send data to IR ACALL delay_100ms ; delay MOV A,#38H ACALL COMM ACALL delay_5ms MOV A,#38H ; 001DL NFXX, DL=1: 8 bit, N=1: 2Line, F=0: 5x7 font ACALL COMM ACALL delay_5ms MOV A,#08H ; Display OFF (0000 1 D C B) ACALL COMM MOV A,#06H ; Entry mode: increment (0000 01 I/D S) ACALL COMM MOV A,#0FH ; Display ON (0000 1 D C B), CURSOR BLINK ACALL COMM MOV A,#01H ; Clear Display ACALL COMM MOV A,#82H ; DD RAM Address 3RD POSITION(First Line) ACALL COMM RET
; Subroutine to send data to IR COMM: CLR LCD_EN ; EN=0
CLR LCD_RS ; RS= 0, Register select (IR) CLR LCD_RW ; RW=0, WRITE MOV LCD_PORT, A ; Send Data SETB LCD_EN NOP NOP NOP NOP CLR LCD_EN ACALL delay_5ms RET
YCCE/ECE/MANUAL-8051/PTK/APD 15
;Subroutine to send data to DR DISP: CLR LCD_EN ; EN=0
SETB LCD_RS ; RS=1, Register select (DR) CLR LCD_RW ; RW=0, WRITE MOV LCD_PORT,A ; Send data SETB LCD_EN NOP NOP NOP NOP CLR LCD_EN ACALL delay_1ms RET
; Subroutine For Delay delay_1ms: MOV R0, #02H ; N = 2 2/1
L2: MOV R1, #0FEH ; N = 254 2/1 L1: DJNZ R1, L1 ; Decrement R1& JNZ 2/2 DJNZ R0, L2 ; Decrement R0& JNZ 2/2 RET
delay_5ms: MOV R0, #0AH ; N = 10 2/1 L22: MOV R1, #0FEH ; N = 254 2/1 L21: DJNZ R1, L21 ; Decrement R1& JNZ 2/2 DJNZ R0, L22 ; Decrement R0& JNZ 2/2 RET
delay_100ms: MOV R0, #0C8H ; N = 200 2/1 L32: MOV R1, #0FFH ; N = 255 2/1 L31: DJNZ R1, L31 ; Decrement R1& JNZ 2/2 DJNZ R0, L32 ; Decrement R0& JNZ 2/2 RET
; Message Here ORG 0100H DB 'Dept. of ECE$' DB 'YCCC8051/PTK/APD$' END
--------------------------------------------------------------------------------------------------------------------- Program #2
; Blink LED connected to P0.4 $MOD51 LED EQU P0.4 ORG 0000H MOV SP,#40H ; Initialise stack pointer
L1: SETB LED ACALL delay_1sec CLR LED ACALL delay_1sec SJMP L1 ; Subroutine For Delay delay_1sec: MOV R2,#08H L44 MOV R1,#0F4H L42: MOV R0,#0FFH L41: DJNZ R0,L41 DJNZ R1,L42 DJNZ R2,L44 RET END
YCCE/ECE/MANUAL-8051/PTK/APD 16
Program #3 ;Display 0 to 9 continuously in loop ; 7 segment display common anode connected to P0.3---P0.0 (4LSB)
$MOD51 ORG 0000H
START: MOV SP,#40H L5: MOV R1,#00H ;START WITH '0' L1: MOV A,R1 ; in ACC MOV P0,A ; send it to display ACALL delay_2sec ; wait 2 sec INC R1 CJNE R1,#0AH,L1 ;Compare for > 9 SJMP L5 ;Subroutine for delay of 2 sec delay_2sec: MOV R2,#10H L4: MOV R3,#0FFH L3: MOV R4,#0FFH L2: DJNZ R4,L2 DJNZ R3,L3 DJNZ R2,L4 RET END
YCCE/ECE/MANUAL-8051/PTK/APD 17
7. Serial data transfer via RS 232 port 7.1. Using HyperTerminal: You can run serial data transfer program on DB-51, you can get display on
computer monitor using hyper terminal program. To use hyper terminal program of your
PC steps are as follows:
Click on start >> programs >> accessories >> communications >> hyper
terminal >> new connection >> name XYZ_1 >> connect using COM1
Properties (configure) as follows:
Bits per second = 9600
Data bits = 8
Parity bit = none
Stop bit = 1
Flow control = none
Properties (settings) as follows:
• Window keys
• Ctrl+H
• Simulation VT100
Save the settings
Now you can use hyper terminal program (XYZ_1) to see key no of pressed key on PC
terminal
7.2. Baud rate setting of microcontroller
Timer 1 Baud Rate Reload Value
Fosc
SMOD C/T Mode Reload
Value 19.2K 11.059MHz 1 0 2 FDH
9.6K 11.059MHz 0 0 2 FDH
4.8K 11.059MHz 0 0 2 FAH
2.4K 11.059MHz 0 0 2 F4H
1.2K 11.059MHz 0 0 2 E8H
137.5 11.059MHz 0 0 2 1DH
YCCE/ECE/MANUAL-8051/PTK/APD 18
8. Hardware description 8.1. DB – 51 kit on board Components
Microcontroller P89v51RD2 (8051 family)
RTC1307 (64 x 8 Serial Real-Time Clock)
AT24C32 (Two wire serial EEPROM)
MAX232
One seven segment display
One LED
ISP switch
Reset switch
7447 (BCD to 7 seg driver)
ULN 2803 stepper motor driver
Connector for RS232, LCD, Stepper motorI/O bus & power supply
8.2. Layout Map of components & connectors on the board:-
YCCE/ECE/MANUAL-8051/PTK/APD 19
8.3. Circuit Diagram
Interfacing of LCD, 7segment, LED’s, Stepper Motor, I2C
LCD (16x2) 7SEGMENT (BCD)
RS RW EN D7 - D0 D C B A
P0.5 P0.6 P0.7 P2 P0.3 P0.2 P0.1 P0.0
STEPPER MOTOR I2C
1 2 3 4 5 SCL SDA
12V P3.7 P3.6 P3.5 P3.4 P3.2 P3.3
LED DC SUPPLY
1 2 3 4 5 12V - GND 5V - GND
P0.4 - - - - J10 J11
P00P01P02P03p04p05p06p07
D0D1D2D3D4D5D6D7
RXDTXDSCLSDAST1ST2
ST3ST4
P00P01P02P03P04P05P06P07
GN
D
VCC
VC
C
P07 D
0D
1D
2D
3D
4D
5D
6D
7
P06
P05
VC
CG
NDVC
CG
ND
VC
CG
ND
GND
TXDRXD
GND
SDASCL
SDASCL
GN
D
P04
GN
DV
CC
12V VCC
GND
VC
C
GN
D
P00P01P02P03
VC
C
ST4ST3ST2ST1
12V
12V
12V
GN
D VC
CG
ND
XTAL218
XTAL119
ALE30
EA31
PSEN29
RST9
P0.0/AD0 39
P0.1/AD1 38
P0.2/AD2 37
P0.3/AD3 36
P0.4/AD4 35
P0.5/AD5 34
P0.6/AD6 33
P0.7/AD7 32
P1.01
P1.12
P1.23
P1.34
P1.45
P1.56
P1.67
P1.78
P3.0/RXD 10
P3.1/TXD 11
P3.2/INT0 12
P3.3/INT1 13
P3.4/T0 14
P3.7/RD 17P3.6/WR 16P3.5/T1 15
P2.7/A15 28
P2.0/A8 21
P2.1/A9 22
P2.2/A10 23
P2.3/A11 24
P2.4/A12 25
P2.5/A13 26
P2.6/A14 27
U1
AT89C51
VI1 VO 3
GN
D2
U27805
123456789
J1
CONN-SIL9
12345678
J2
CONN-SIL812345678
J3
CONN-SIL812345678
J4
CONN-SIL8
12345678
J5
CONN-SIL8
X1CRYSTAL
C1
100n
C2
100n
R110k
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
J6CONN-SIL18
R210k
T1IN11
R1OUT12
T2IN10
R2OUT9
T1OUT 14
R1IN 13
T2OUT 7
R2IN 8
C2+
4
C2-
5
C1+
1
C1-
3
VS+ 2
VS- 6
U3
MAX232
C3
100n
C4
100n
C5
100nC6
100n
C710
162738495
J7
CONN-D9F
C810u
R310k
VBAT 3
X11
X22
SCL 6SDA 5
SOUT 7
U4
DS1307
SCK 6SDA 5WP 7
A01 A12 A23U5
24C32A
X2CRYSTAL
C9
330n
123
J8
CONN-SIL3
D1
1N4001D2
1N4001
C11100n
C12100n
D3LED
R4330k
JP1JUMPER
JP2
JUMPER
C101000u
D8LED
R9330k
A7 QA 13
B1 QB 12
C2 QC 11
D6 QD 10
BI/RBO4 QE 9
RBI5 QF 15
LT3 QG 14
U6
7447SEVEN1DISP1
1B1
2B2
3B3
4B4
5B5
6B6
7B7
8B8
1C 18
2C 17
3C 16
4C 15
5C 14
6C 13
7C 12
8C 11
COM 10U7
ULN2803MODFILE=ULN280X.MDFPACKAGE=DIL18
12345
J9
CONN-SIL5
1 2
J10CONN-SIL2
1 2
J11CONN-SIL2
9. Appendix Pins and signals of 89C51