89S52 Micro Controller Interfacing
89S52 Micro Controller Interfacing
com
Introduction
There are many topics that we need to study, understand and then verify to acquire the capability of designing and building microcontroller based systems such as: a 24-Hr Clock or a
Taximeter or a Digital Weighing Machine or a Prepaid KWH Meter or a similar.
Now, the question is: Which topics to study and verify first? It is a difficult question and there exits no straightforward answer! However, like many successful people, I have found that the following guidelines could help getting quick interest into the works involving microcontrollers.
i. ii. Let us take an example program from Chpater-5 or Chpater-6 of this book. Follow the steps as outlined in the example and observe the results. Open the source code of the program. Let us try to understand the need of every instructions of the program. While studying the program codes, we must remember that the program instructions are closely related with the hardware on which it works. Let us now, try to rewrite the program in our own ways and observe that the new program still provides the same result. This is the beginning point of learning the procedures of microcontroller based system design.
iii. iv.
To design, develop and build a microcontroller-based system, we need a learning/development tool similar to MicroTalk-8051, which has been pictured at the back of the cover sheet of this book. A development tool is equipped with all kinds of commonly used peripheral controllers, RAM, local hexadecimal keyboard, serial link, breadboard, edge connectors and a good number of ROM and CD-based subroutines. A user places the interface circuitry on the breadboard; connect these with the MCU using the edge connectors and the hookup wires. The user then develops the control program using IBMPC and the assembler. The binary codes are then transferred into the RAM of the trainer using the serial link of the PC. The program could be easily edited and modifies using the local keyboard and the PC. MCU based system design becomes a matter of enjoyment using development system like Microtalk-8951 and the similar. Unfortunately, the development tools are costly items and are not within the reach of the students and the amateur designers. The solution is the development of a student version of the MicroTalk-8051, which is: CKIT-06A. The CKIT-06A is a very low cost miniature microcontroller learning/development system using Atmel 8-bit CISC microcontrollers of type: 89S51, 89S52 and 89S8252. The CKIT-06B supports Atmel 8-bit 20-pin RISC microcontroller of type: AT90S2313. The CKIT-06C supports 8-bit 40-pin RISC MCU of type: AT90S8515. The CKIT is equipped with edge connectors, breadboard, +5V supply and a Line Printer (LPT) cable. A user can develop his circuitry on the breadboard; develop the control program using the IBMPC and assembler. The binary cods are then written into the code memory (EEPROM) of the MCU using the LPT port of the IBMPC and a driver, which has been supplied with the CD that accompanies the CKIT. It is very annoying to develop MCU based system using CKIT because it does not provide any facility to debug a program. If the program works its fine; otherwise the modified or the extended codes of the program required to be re-written into the MCU, which reduces the endurance of the EEPROM of the MCU. However, the MCU supports 1000 times write operations within its EEPROM and it is sure that a user would be able to develop his working control program within 100 attempts.
R2
J1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
J2
P10 P11 P12 P13 P14 P15 P16 P17 RST P30 P31 P32 P33 P34 P35 P36 P37 XT1 XT2 GND Vcc P00 P01 P02 P03 P04 P05 P06 P07 EA/ ALE PSEN/ P27 P26 P25 P24 P23 P22 P21 P20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21
D1
C3
1
D4
U5
C2
T1
C1 + -
Y1
U1
D3
D2
CKIT
D3
1 + -
7805 2
+5V
220V
6V
0V
C1 U5 1000uF
6V
T1 LV D2
C3 0.1uF
+ C2 220uF 0V
Circuit Diagrams
3.1 Connection Diagram Between LPT Port and 40-Pin ZIF Socket
LPTCR (037Ah)
CR0
LPT Port
14
1 2 3 4 5 6 7 8
`
RST
15
18 Y1 11.0592MHz
XT2
CR2
16
` 17
19
20 40
XT1
GND Vcc
COM
18 19 20
+5V
LPTDR (0378h)
DB7
21
22 23 24
9 10 11 12 13
Data In
Clock In
6 7 8
D1
Data Out
LPTSR (0379h)
SR4
25
0V
P10
1001x: GM : 02-05
Figure-3.1: Connection Diagram between LPT Port and 40-pin ZIF Socket
As indicated in the diagram of Fig-3.1, the pins of the 40-pin ZIF socket (assuming that the ZIF contains 89S51 MCU) are permanently connected with the indicated pins of the LPT port of the IBMPC.
The P10-pin of the 89S51 is directly connected with the LED, D1. The internal pullup resistor of P10 limits the current. The LED (D1) would be helpful to monitor the status of the functionality of programs.
J1
0V
J2
40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
P10 P11 P12 P13 P14 P15-MOSI P16-MISO P17-SCK RST P30-RxD P31-TxD P32-INT0/ P33-INT1/ P34-T0/ P35-T1/ P36-WR/ P37-RD/ XT2 XT1 GND
Vcc AD0-P00 AD1-P01 AD2-P02 AD3-P03 AD4-P04 AD5-P05 AD6-P06 AD7-P07 Vpp-EA/ PROG/-ALE PSEN/ A15-P27 A14-P26 A13-P25 A12-P24 A11-P23 A10-P22 A9-P21 A8-P20
20
1001
The power up reset circuit for the 89S51 is not included in the CKIT-06. Therefore: i. ii. After storing the program codes in the code memory (the flash) using the LPT port, the RST-pin could be activated MCU using the LPT port and software instructions. The following reset circuits could be built on the breadboard of the CKIT and be connected with the appropriate reset pins of the MCUs. The LPT cable should be open.
+5V + 100uF
K1
4k7 0V
Pin-9 of 89S51
+5V
J2
40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21
Y1
20
1004
After storing program codes within the MCU, the following reset circuitry (same as for 89S51) should be included. The EA/-pin should also be tied to LH. And then activate the reset switch to run the stored program. Connect the following reset the with the reset pin of the 89S8252 microcontroller.
+5V
+ 100uF
Pin-9 of 89S8252
K1
4k7 0V
4.1 Familiarization with ASM51 Assembler and Quick Function Check of the 89S51 CISC (Compact Instruction Set Controller) Microcontroller
In this functional check, we would store a small program inside the code memory of the 89S51 microcontroller. When the program is executed, the LED-D1 connected at the P10-pin would start blinking. Let us now carry out the following steps:
1. 2. 3. 4. 5. Read the diagram of Fig-3.1 and 3.2 for the electrical connections between the LPT port, 89S51 MCU and the J1 and the J2 edge connectors of the CKIT. Copy the contents of the folder CKIT of the CD that has been supplied with CKIT in the hard disk in the path: C:\CKIT Boot the IBMPC in pure DOS mode and then enter into the path: c:\ckit. Type EDIT at the DOS prompt and then hit the carriage return. A screen would appear called DOS screen. Now, type the following program statements and save it as: c:\ckit\p41.asm. This program could be found in the CD that accompanies the CKIT.
$MOD51 ; this file includes the definitions of various symbolic names ; you may open the mode51 file and read the contents ; you may open the asm51.doc file to read about the asm51 assembler $OBJECT(c:\CKIT\p41.OBJ) ; P41.OBJ file contains the Intel-Hex formatted code ; for the Binary code of the program P41.asm. ; read the CKIT manual for the detailed structure of the Intel-Hex ; formatted file. ORG DB DB DB ORG MOV MOV L1: SETB LCALL LCALL LCALL LCALL LCALL CLR LCALL LCALL LCALL LCALL LCALL LJMP TDELAY: MOV AGN1: MOV AGN2: DJNZ DJNZ RET END 0000H 02H ; after power up the MCU looks for instruction at 0000H 00H 10H ; the program execution now begins at: 0010H: 0010H SP, #70H ; stack pointer set. See MCU data structure PSW, #00H ; Bank-0 Selection. Fig-21 of the PSPKIT Manual P1.0 ; TDELAY ; TDELAY TDELAY ; TDELAY ; TDELAY P1.0 ; TDELAY ; TDELAY TDELAY ; TDELAY TDELAY ; L1 ; R5, #0FFH R6, #0FFH R6, AGN2 R5, AGN1 LED1 is ON calling Time Delay calling Time Delay calling Time Delay LED1 is OFF calling Time Delay calling Time Delay calling Time Delay repeat
6. 7.
Save the program and exit to DOS. Now convert the P41.asm program into P41.obj file. The p41.obj file would automatically be saved in the path: c:\ckit\p41.obj as per declaration with the include directive $ at the top of the program. Procedures: i. Type ASM51 and hit the carriage return. ii. Type C:\ckit\p41.asm in response to: Source File drive and name [.ASM]: iii. The program would terminate to DOS prompt with zero errors. Now convert the P41.obj program into P41.bin. Why? The P41.obj program is an Intel-Hex formatted file, which is suitable to transfer over COM port of the IBMPC. The ISP programming technique of the 89S51 demands that the program codes should be in the Binary format. The P41.obj file would now be converted into P41.bin using the EPW512.exe program (a third party program being used freely with no obligation). The procedures are: i. ii. iii. iv. v. vi. vii. Type EPW512 at the DOS prompt. A DOS menu would appear. Follow the menu and load the file: c:\ckit\p41.obj Type I in response of: < B > in, < I > ntel Hex, < M > otorola S Hex Type 0000 in response of: File start seg. (0000) : Type 2 in response of: Unused bytes will be < 1 > 00, < 2 > FF, < 3 > Dont care: Note down the end address as: 0047 (it may vary program to program) Follow the menu.
8.
Follow the menu and save the converted file as: c:\ckit\p41.bin. Be careful to type the correct start and end addresses. Quit the DOS menu and exit to DOS prompt. Connect the LPT cable with the LPT port of the IBMPC. The EA/-pin is already tied with +5V Build the following reset circuit on the breadboard and connect it with the RST pin (pin-9) of the 89S51 +5V MCU. You may omit this circuit if you wish.
+ 100uF 4k7 0V
K1
Pin-9 of 89S51
14. 15.
Apply power to the CKIT. Let us now store the codes of the program p41.bin on to the code memory of the 89S51 MCU. The procedures are: i. At the DOS prompt, type 89S51 and hit carriage return. ii. Follow the menu iii. Erase the Chip. Write the chip. [type small letter y for Yes and n for No]. Type: Capital letters for digits. Execute the downloaded program by executing P89s51.exe from the path: C:\ckita The LED-D1 should statrt5 blinking.
5.1 Functionality Check of INT0/-pin of 89S51 MCU of the CKIT-06A In this example, we configure Pin-12 of the MCU to operate as Interrupt Input Line.
Interrupting Device (K1) 12
+5V
cngm et\ch8n\8-9n
EA=1
INT0/ (P32)
SWA
0 1
IT0=0,1
IE0
SWB
SW C
TCON (88H)
1100
EX0
EA
IE (A8H)
Working Principles:
a. b. c. d. e. f. Assume that the SWA is at position 1, which could be done by writing LH at IT0-bit of the TCON register. When a High-to-Low going signal appears at Pin-12, the IE0-bit of TCON register is set to LH. Assume that the switches SWB and SWC are closed. These switches could be opened and closed as required by manipulating the relevant bit of the IE register. The MCU would be automatically interrupted. The MCU would suspend the mainline program and would jump to the Interrupt Service Routine due to INTO (ISURINT0) at the address: 0003H. This is known as Vectored Interrupt. If the switches SWB and SWA are opened, then the user can still detect the occurrence of an activating signal at Pin-12 by reading the IE0-bit and the user can deliver the interrupt services. This is known as Polling Interrupt.
Functional Check:
a. b. c.
Mainline Program (MLP) located at: 0000H 0010H. Output: The LED-D1 would be continuously blinking. The ISURINTO program is located at: 0003H 0030H Output: The LEDD1 would blink for 5 times with a long gap in between them. At the end of the execution of ISURINT0, the MLP would normally be resumed.
Procedures:
a. b. c. d. e. f. g. h. Use the LPT port and store the program C:\CKITA\P51.bin into the 89S51 MCU. Run the downloaded program either by activating the LPT port or the RST switch. The MLP should start normally. After a while, take apiece of hookup wire and gently touch Pin-12 to ground potential. The MLP should be suspended. The ISURINT0 should start and comes to an end. The MLP should resume. Repeat the process.
5.2 Functionality Check of Pin-14 as External Event Counter In this example, we configure Pin-14 of the MCU to operate as an External Event Counter. The Pin-14 would receive external LH-to-LL transitions and the internal Counter-0 would count them.
18 XT2
OSC
1/12
f1=921.6KHz
Counter-0
SW2 SW1
Address:8AH
TL0
TF0
C 0-T0/=1
14
P34
TH0 (8-bit)
534b
Address:8C H
Working Principles:
1. Timer/Counter-0 of MCU operates as Counter-0 when the internal switch SW1 is connected to Pin14 and the mode of operation is configured properly with the help of TMOD register. We say that the there is a Timer-0 operation when the SW1 is internally connected with the internal oscillator signal. The open/close condition of SW2 is controlled by TCON register. Initially both TL0 and TH0 are loaded with some user defined values. The counter-0 counts an external event and increments the TL0. And when the content of TL0 rolls over from all 1s to all 0s, the TF0-bit of the TCON register is set to LH. At the same time, the TL0 is automatically loaded with the content of TH0 register. A user can poll the TF0-bit to know that the counter has been filed up. If interrupt structure is enabled then the setting of the TF0-bit can be brought to the attention of the MCU through vectored interrupt.
2. 3.
4.
Functional Check:
We intend to count the negative zero crossing points of the ac line frequency. The counter-0 would be employed to count 50 (fifty) ve crossing points, which would amount to 1-sec time delay. After each 1-sec time delay, the MCU can drive an external 7-segment display device to indicate amount of time elapsed.
Procedures:
1. 2. Refer to Fig-5.3, build the following zero crossing circuit and the 7-segment display unit on the breadboard of the CKIT. Download and execute program: C:\CKITA\P52.bin. The DP0 would count the time and be advancing by 1-sec.
+5V
+5V
20m S
D3 (on C KIT)
MCU
14 T0/(P34)
8x560R
P07
DP0
p
R1 : 1k5
R2 1k5
Q1: C 828
P00
0V
P20
a cc
1003x : GM : 03-05
Figure-5.3: Circuit to Detect and Display 1-sec Time Tick from AC Line Frequency
RS<-->TTL
U2 : MAX232
RXTTL
RxD
9-Pin Cable
4 5
IBMPC
Pins
1
C2
+ 1uF
TXRS
Holes
1 6 2 7
CD/ DSR/
10
P30
12 R1OU T
R1IN 13
2 7
RXRS
RTS/
+5V
Address: 99H
Tx Buffer
TxD
TXTTL
11
8x560R
DP0 p
11 T1IN
T1OUT 14
Port-3 : B0H
P07 P00
P30 P31 P32 P33 P34 P35 P36 P37
P31
+ 1uF
1 3
3
8
TXRS
cc
P2.0
C1 12 13 14 15 16 17
16 2 6
C3 RXRS
1uF + C4 1uF +
15 0V
CTS/ DTR/
4 9 5
4 9
+5V
5
COM
0V
753x : GM : 10-05
GND 15
VCC 16
+5V
Setup Procedures:
1. 2. 3. 4. Place the zero crossing circuitry and the 7-segment display device (DP0) on the breadboard and connect it with the MCU as per diagram of Fig-5.4. Place the MAX232 chip (RS TTL Converter) on the breadboard and connect it with the MCU as per diagram of Fig-5.4. Also install the capacitors C1-C4 in correct polarity as per diagram of Fig-5.4. Obtain a 9-pin serial port cable and short the lines: 7,8 and 1,4,6 as per circuit diagram of Fig-5.4. Attach the hole-side of the 9-pin connector with the COM1 port of the IBMPC. The other side of the 9pin cable should be connected with the MAX232 chip as per circuit diagram of Fig-5.4.
Functional Check:
1. 2. 3. 4. Boot the IBMPC in the pure DOS mode and enter into path: C:\CKITA Download (write) the program C:\CKITA\P53.bin into the MCU and execute the program. From the DOS prompt of the PC, execute the program: c:\CKITA\SERCHK.EXE. Press any key from 0-9 in the keyboard of IBMPC and it would be instantly displayed on DP0 of the trainer.
Working Principles:
1. The MCU keeps polling the receiver port and looks for the arrival of a character. The ASCII code of the character is read from the receiver buffer. It is converted to CC-code and is then displayed on DP0. The MCU also sends the received character back to the IBMPC. The PC displays the character on CRT. The IBMPC receives the ASCII code from the buffer and displays them on the CRT monitor. The IBMPC keeps polling the keyboard and whenever a close key is found, the corresponding ASCII code is instantly transmitted to the MCU.
3. 4.
10
89S51
U14
DP0
DP10
D7 D6 D5 D4 D3 D2 D1 D0
R-W /
D-I/
VA
Vdd
Vss L+ L-
14 13 12 11 10 9 8 7
R10:1k5
Viewing Angle
A14(P27)
A10(P22) 0V R D/(P17) W R/(P16)
13 14 15
2 1
U15: 74LS138
U16: 7486
747x-05:GM
Setup:
1. 2. 3. 4. 5. Refer to Fig-5.5 and place the device U14 (LCD), U15 (74LS138) and U15 (7486) on the breadboard of the CKIT and connect them together along with 89S51 MCU using the hookup wires. Use LPT and then store the program c:\ckitA\P54a.bin into 89S51. Execute the program P55a.bin, the LCD should show character 3 at DP0 position of 1st Line. Erase the MCU and store c:\ckita\p54b.bin. Execute the program, the LCD shows: 2 at DP2 position of the 2nd line. Erase and store the program C:\CKITA\P54c.bin. Execute the program. The LCD shows the following message:
11
To See at Dark
0V
15 16
+5
K1
5.5 Interfacing 2x16 Character LCD with MCU as a Port-operated Device (8-Bit Data)
Let us interface a 2x16 character LCD unit with the 89S51 MCU of the CKIT-06A. The LCD would be accessed as a Bus Operated device. In a bus-operated device, the data read/write operations are carried out using the bus signals (Address, Data and Control), which are automatically generated at the time the instructions are executed. The disadvantage of a busoperated system is that there is wastage of Port Lines of the MCU, which cannot be tolerated in a Single Chip solution. In Section-5.5, we would operate the LCD device as a port-operated device in which the bus-signals (Address, Data and Control) are generated artificially using instructions. The advantage of port-operated device is that there is a savings of many port lines, which could be easily used for some other purposes.
89S51
U14
DP0
DP10
D7 D6 D5 D4 D3 D2 D1 D0
R-W /
D-I/
VA
Vdd
Vss L+ L-
14 13 12 11 10 9 8 7
R10:1k5
Viewing Angle
8x4k7 +5V
A10(P22)
747y : 05:GM
Setup:
1. 2. 3. 4. 5. Refer to Fig-5.6 and place the device U14 (LCD) and resistor network RN1 on the breadboard of the CKIT and connect them together along with 89S51 MCU using the hookup wires. Use LPT and then store the program c:\ckitA\P55a.bin into 89S51. Execute the program P55a.bin, the LCD should show character 7 at DP0 position of 1st Line. Erase the MCU and store c:\ckita\p55b.bin. Execute the program, the LCD shows: A at DP2 position of the 2nd line. Erase and store the program C:\CKITA\P55c.bin. Execute the program. The LCD shows the following message:
12
To See at Dark
0V
15 16
+5
K1
5.6 Interfacing 2x16 Character LCD with MCU as a Port-operated Device (4-Bit Data)
89S51
U14
DP0
DP10
D7 D6 D5 D4 D3 D2 D1 D0
R-W /
D-I/
VA
Vdd
Vss L+ L-
14 13 12 11 10 9 8 7
4x4k7
A9(P21) A8(P20) 0V +5V 0V
+5V
R10:1k5
Viewing Angle
A10(P22)
748y : 06:GM
Setup:
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. Place the LCD and RN1 on the breadboard of the CKIT. Use hookup wire and connect the LCD and RN1 with the 89S51 MCU as per circuit diagram of Fig-5.7. Store the program c:\ckita\p56a.bin into the MCU and execute it. The LCD should shoe character 7 at DP0 position of the 1st line. Erase the chip and then store program p56b.bin. Execute the program p56b.bin. The LCD should show the character C at DP2 position of the 2nd line. Erase the MCU. Store the program c:\ckita\p56c.bin. Execute the program: C:\ckita\p56c.bin. The LCD should show the following message on the display:
13
To See at Dark
0V
15 16
+5
K1
5.7 Interfacing 7-Segment Display Devices and Walking 1s Keyboard using 8279 Controller In any microcomputer system, the display unit and the keyboard are the two most important IO devices. The display is usually built using 7-segment display devices and the keyboard is made using PCB mountable ON/OFF keys. The 8279 are a MPU/MCU bus compatible versatile IO controller that allows interfacing both the 7-sement display devices and the ON/OFF keys. However, in MCU applications, the display and the keyboard are driven using the built-in port lines, as we will find in Section-5.8.
89S51
AD7/P07 D7 D6 D5 D4` D3 D2 D1 D0
U12: 8279
A3 A2 A1 A0 B3 B2 B1 B0 h g f e d c b a
DP0
DP7
DP8
DPF
AD0/P00
cc0
cc7
cc8
ccF
S7/
En/ C B A S0/
S7/
A14(P27) A8(P21)
CS/ A (C -D/)
ALE
CLK
U13: 74138
U14: 74138
U15: 74138
A B C
IRQ
0V RST
R L0 R L1 R L2 R L3 R L4 R L5 R L6 R L7
K00
K07
Setup:
1. 2. 3. 4. Consult data sheets for 8279, 74138 to get their pin numbers and signal names. Place the U12, U13, U14, U15 , CC-type 7-Segment devices and the keyboard on the breadboard. use hookup wire and connect the devices of the breadboard with the 89S51 MCU as per circuit diagram of Fig-5.8. Store the program C:\ckita\p57a.bin into the MCU and execute it. The display should the changing pattern of: blank, 0, 1, 2, 3,,E,F , ., 0, 1.. Erase the chip and then store the program c:\ckita\p57b.bin. Execute the program. Press the keys and find that the DP0DP1 positions show the Scan Code of the pressed down key.
5. 6.
14
En C B A S0/
1200: Gm : 03-06
W R/(P36) R D/(P37)
WR/ RD/
S0/
S7/
5.8 Interfacing 7-Segment Display Devices and Walking 1s Keyboard using MCU Port Lines
+5V 8x4k7
89S51
P07
DP0
h g f e d c b a
cc0
DP7
DP8
DPF
P00
cc7
cc8
ccF
S0/
U13: 74138
P10 P11 K00
D C B A
U12: 74154
K07
Setup:
1. 2. 3. 4. Consult data sheets for 8279, 74154 and 74138 to get their pin numbers and signal names. Place the U12, U13 and CC-type 7-Segment devices and the keyboard on the breadboard. Use hookup wire and connect the devices of the breadboard with the 89S51 MCU as per circuit diagram of Fig-5.8. Store the program C:\ckita\p58a.bin into the MCU and execute it. The display should the changing pattern of: blank, 0, 1, 2, 3,,E,F , ., 0, 1.. Erase the chip and then store the program c:\ckita\p58b.bin. Execute the program. Press the keys and find that the DP0DP1 positions show the Scan Code of the pressed down key.
5. 6.
15
SF/
A B C
S0/
S7/
5.9 Generation of PWM (Pulse Width Modulated) Signal using Port-operated 8253
MCU
ALE 30
PIT
1 2 3 4 5 6 7 8 21 20 19 23 22 24 12
50Hz Line
GT0 C K0 OT0 GT1 C K1 OT1 GT2 C K2 OT2
11 9 10 14 15 12 16 18 17
32 33 34 35 36 37 38 39
24 22 21 26 25
D7 D6 D5 D4 D3 D2 D1 D0
C S/ A1 A0 WR/ R D/ Vcc GND
C h1
y
One Shot
x 20m S
C h2
+5V
Oscilloscoipe
R 2: 1k5 D3 R 1: 1k5
Q1 : C 828
0V
Vcc 40 GND 20
U1 : 89S51
8253
C 1: 104
Theory: Pulse Width Modulation means Changing the ON Time (Mark) Width of a Pulse. In Fig-5.10, let us see that the period of the signal of Ch-2 of the oscilloscope is fixed and it is 20mS. But the OFF Time (Space), x is variable and hence the ON Time (Mark) y is also variable. Here, we have a pulse of variable width, which could be used (and of course after suitable conditioning) to control the rotating speed of a fan, the luminescence of a dim light and so on. In this example, we will learn and practice the procedures of generating a PWM signal using the Timer-0 of the 8253. Brief Architecture of 8253: There are 3 identical timers/counters inside the 8253 chips, which could be configured to operate in various mode of operation. In this example, we would initialize Timer-0 as a Programmable One-shot to produce a PWM signal similar to one as shown in Fig-5.10. A square wave signal (SWS) of 20mS duration is obtained from the ac line frequency using a Zero Crossing Circuit consisting of D3, C1, R1, R2 and Q1. When a rising edge of the SWS arrives at the GATE0-pin of Timer-0, the OUT0-pin immediately assumes LL state and remains Low until the content of the internal Counter-0 is emptied. Here, we see that a PWM signal could be obtained by writing variable data inside the 16-bit Counter-0 of the 8253. The readers are referred to data sheet for the detailed study of the architecture and programming of the 8253. Setup:
1. Gently solder a piece of wire with the anode of the D3 of the CKIT-06A. Place the components R1, R2 and Q1 on the breadboard and connect them together using hookup wires as per circuit diagram of Fig-5.10. This circuit is known as Zero Crossing Detector (ZCD). Place an 8253 chip on the breadboard and connect it various pins with the ZCD and the MCU of CKIT. Connect an oscilloscope with the 8253 as per directions of the diagram of Fig-5.10. Store the program c:\ckita\p59.bin inside the 89S51 MCU and execute it. Observe in the oscilloscope that the width of the oneshot pulse is continuously changing. Open the program C:\CKITA\P59.ASM and study it with the assistance of a teacher.
2. 3. 4. 5. 6.
7.
16
PIT-1
1 2 3 4 5 6 7 8 21 20 19 23 22 24 12
50Hz Line
11 9 10 14 15 12 16 18 17
P07 P06 P05 P04 P03 P02 P01 P00 A15(P27) A14(P27) A9(P21) A8(P20)
WR /(P37) R D/(P36)
32 33 34 35 36 37 38 39 28 27 22 21
17 16
D7 D6 D5 D4 D3 D2 D1 D0
C S/ A1 A0
GT0 CT0 C K0 (8000H) OT0 GT1 CT1 C K1 (8100H) OT1 GT2 CT2 C K2 (8200H) OT2
C h1
y
One Shot
x 20m S
C h2
+5V
Oscilloscoipe
CT2
R 2: 1k5 D3 R 1: 1k5
Q1 : C 828
0V
Vcc 40 GND 20
U2: 8253
PIT-2
1 2 3 4 5 6 7 8 21 20 19 23 22
24 12
C 1: 104
D7 D6 D5 D4 D3 D2 D1 D0 C S/ A1 A0
GT0 CT0 C K0 (4000H) OT0 GT1 CT1 C K1 (4100H) OT1 GT2 CT2 C K2 (4200H) OT2
11 9 10 14 15 12 16 18 17
CT2
U1 : 89S51
U3: 8253
Working Principles: The 8253 devices are interfaced with the 89S51 MCU as bus-operated devices. The U2 and U3 are assigned the following addresses for their various internal registers:
Register Name Counter-0 Counter-1 Counter-2 Mode Register Address for U1 8000H 8100H 8200H 8300H Address for U2 4000H 4100H 4200H 4300H
When the MCU asserts address 8000H on the bus, the A15-pin assumes LH and A14-pin assumes LL. The device U1 is selected and U2 is deselected. The opposite occurs at address 4000H
17
3.
Figure-5.12: Data Structure for Converting Six Digit BCD Number into Binary 1. 2. 3. 4. 5. 6. Extract x0 in the form of 0X0 from x1x0 and get (00H 09H) taking positional weight as: 01H for 1. Update output binary table: 48 - 46 Extract x1 in the form of 0x1 from x1x0 and get (00H 5AH) taking positional weight as: 0AH for 10. Update output binary table : 48 - 46. Extract x2 in the form of 0X2 from xx3x2 and get (0000H 0384H) taking positional weight as: 64H for 100. Update output binary table: 48 - 46 Extract x3 in the form of 0x3 from x3x2 and get (0000H 2328H) taking positional weight as: 03E8H for 1000. Update output binary table : 48 - 46. Extract x4 in the form of 0X4 from x5x4 and get (000000H 015F90H) taking positional weight as: 2710H for 10000H. Update output binary table: 48 - 46 Extract x5 in the form of 0x5 from x5x4 and get (000000H 0DBBA0HH) taking positional weight as: 0186A0H for 100000. Update output binary table : 48 - 46.
18
5.12 Converting 40-Bit BINary Number into Equivalent BCD using Horner Rule
Setup:
1. 2. Install a 2x16 character LCD panel on the breadboard and connect it with the MCU of the CKIT-06A as per circuit diagram of Fig-5.7. Open the program c:\ckita\p519.asm and find that the input BIN and output BCD values are associated with RAM locations as follows: LOAD: BIN2BCD: MOV 68H, #12H ; Input BIN Hbyte MOV 5DH, #00H ; to hold BCD HByte MOV 67H, #34H ; MOV 5CH, #00H MOV 66H, #56H ; MOV 5BH, #00H MOV 65H, #78H MOV 5AH, #00H MOV 64H, #90H ; Input BIN Lbyte MOV 59H, #00H MOV 58H, #00H ; to hold BCD LByte Store the program C:\CKITA\p519.bin into MCU and execute it. The as: Bin: 1234567890 Bcd: 078187493520 4. Change the input BIN to FFFFFFFF. Assemble the program P519.asm and convert to P519.bin. Store the program P51.bin into MCU and execute it. The LCD should show as: Bin: FFFFFFFFFF Bcd: 099511627775
3.
Working Principles:
Input BINary (0000000000H - FFFFFFFFH)
Internal RAM Input BCD 68 x9x8 67 x7x6 66 x5x4 65 x3x2 x1x0 64
39
68H 66H 67H 32 31 24 23
LSDigits
15
65H
16
64H
Internal RAM Input BC D Data Order 5D MSDigits y11y10 5C y9y8 BIN2BCD y7y6 5B y5y4 5A y3y2 59 LSDigits y1y0 58 BIN2BCD 5DH 5C H 59H 58H 5BH 5AH 0 0 2 1 8 7 6 5 4 3 11 10 9
Ouput: 12-Digits BCD Data
514x
Figure-5.13 : Data Structure for 40-Bit Binary to BCD Conversion Input BINary Output BCD = b39b38,.,b1b0 = b39x239 + b38 x 238 + . + b1 x 21 + b0 x 20 = (((((( ((((b39)2 + b38)2 + + b3)2 + b2) 2 +b0
When we carefully observe the above expression while moving from right to left, we notice that the bit values (say b0) are always added with something, which is multiplied by 2. This feature is not seen for bit b39. To offer the same feature to the bit b39, we may rewrite the above expression as: Output BCD = (((((( ((((IBCDx2 + b39)2 + b38)2 + + b3)2 + b2) 2 +b0 Where, IBCD (Initial Partial BCD) is assigned the value of 00.
This expression is known as Horner Rule due to W.G. Horner, who used it in the year of 1819 (the original rule belongs to Isaac Newton in 1711) for algebraic simplification. This is a particular case of the generalpurpose polynomial of the form: A(x) = anxn + an-1xn-1 + ..+ a1x1+ a0 x0 Golam Mostafa (the author) of Ahsanullah University of Science and Technology (AUST), Dhaka for the 1st time in Bangladesh in the year of 1998, carried out the low-level implementation of the Horner Rule to convert a 32-bit BINary number into equivalent BCD number in connection with the design of Digital Weighing Machine using 8085/8086/8051 architectures.
19
3.
Working Principles:
Input-2: Multiplicand (0000H - FFFFH)
Internal RAM Input BIN 5B x3x2 x1x0 5A
4B 4A
Ouput; Product (00000000H- FFFE0001H)
Internal RAM Input BCD Data Order 5F r7r6 MSDigits 5E r5r4 r3r2 5D r1r0 5C LSDigits
c3c2 c1c0
BIN2BCD
BMULT
Carry
Carry
Carry
X
519
519
519
5CH
5DH
5EH
5FH
47 46 45 44 43 42 41 40
B-reg
: Multiplicand : Multiplier
MUL AB
yy
`r3'r2' r1'r0' = (x1x0) x (y1y0) : L1 = (x3x2) x (y1y0) : L2 = (x1x0) x (y3y2) : L3 = (x3x2) x (y3y2) :L4
A-reg
r7''''r6''''
r7r6
r5''''r4''''
r5r4 c3c2
A-reg
20
4.
5.
6. 7.
8.
T1
Con
Variable
RAM Loc
T2
Con
Variable
RAM Loc
T3
Con
Variable
Dividend
0D 0C 0B 0A 09 08
BDIV
764x : GM : 10-05
17 16 15 14 13 12 11 10 0F 0E 0D
C9 C8 C7 C6 C5 C4 C3 C2 C1 C0 R
MERG
0D 0C 0B 0A 09 08 C9C8 C7C6 C5C4 C3C2 C1C0
Residue
Figure-5.17: Data Structure for 40-Bit by 8-Bit Binary Division using GCR-Method
21
Data Structure:
Immediate Data
56H 34H 12H
1201:GM :03-06
RAM Locations
0A 09 08
EEPROM Locations
00EC 00EB 00EA
RAM Locations
EC EB EA
LCD
Write:12,34,56 Read: 12,34,56
Figure-5.18: Data Structure for the Process of Writing into EEPROM of 89S8252 MCU
Working Principles:
Let us open the program c:\ckit\p522a.asm and we find that the writing process into the EEPROM of the 89S8252 MCU involves the following steps: 1. 2. The data 12H, 34H and 56H are written into RAM locations 08H 0AH for matter of convenience. However, the data could be directly written into the EEPROM. The rules for performing data read/write operations into the EEPROM of the MCU are clearly stated into the data sheets of the MCU. We follow the data sheets and copy the contents of RAM locations 08H-0AH into EEPROM locations 00EAH-00ECH. The 3-byte data are read back from the EEPROM and are saved into RAM locations EAH-ECH. The content of the locations EAH-ECH are displayed on the LCD to visualize that the data have been correctly written/retrieved into/from of the EEPROM of the MCU.
3. 4.
22
5.16 Functionality Check of the SPI (Serial Peripheral Interface) Port of 89S8252.
The four port pins (P1.4-P1.7) of the 89S8252 microcontroller could be configured to operate as a High Speed Synchronous Serial Peripheral Interface Port (SPI Port) to exchange data with compatible devices like:
i. ii. iii. Another 89S8252 microcontroller AT25040 Serial EEPROM ADE7756 Energy Measurement Chip (EMC)
In this section, we shall carry out a functional test of the SPI port of the 89S8252 MCU using an ADE7756 EMC chip. The set up consists of:
i. ii. iii. Placing the EMC chip on the breadboard of the CKIT-06A. Placing an 89S8252 MCU into the 40-pin socket of the CKIT And then connecting the 89S8252 and the ADE7756 as per circuit diagram of Fig-5.19.
89S8252 MCU
P14(SS/) 5 1
ADE7756 EMC
RST/
AVdd AVdd
3 2
+5V
0V
17
NC
MOSI(P15) MISO(P16) SCK(P17) 6 7 8 20 19 18
8 10
C2 0.1
+ C1 47uF
CLKOUT CLKIN
16 15
Y1 3.58M Hz
V2P V2N
7 6
Vol Channel
V1P V1N
4 5
Curr Channel
867 : GM : 03-05
To be sure that the SPI Port of the MCU is functioning properly, we shall perform data read/write operations on the Mode Register of the ADE7756 chip. The particulars of the Mode Register are:
i. ii. iii. Size Operation Mode Content after Power up Reset : 16-bit : Read and Write : 000CH
Writing 1234H (New Data) into Mode Register and Reading it Back (p523b.asm)
Download program p523b.bin and execute it. The LCD should show: MR_Read:1234H.
23
DP0
DP1
DP2
DP3
DP4
DP5
8x560R
P07
HRS
p
M IN
SEC
+5V
P00
20m S
a cc
cc
cc
cc
cc
cc
D3 (on C KIT)
R1 : 1k5
R2 1k5
14
T0/(P34)
Q1: C 828
0V
1002x : GM : 03-05
MCU
Figure-6.1: CKIT-06A Based Circuit for the 24-Hr Clock System 2. 3. 4. 5. 6. A: Boot the PC in pure DOS mode and enter in the path: C:\CKITA Connect the CKIT with the PC using the LPT port. Store the program C:\CKITA\CK24HR.BIN in the code memory of the MCU. Execute the program: CK24HR. The 24-Hr Clock should run. If the clock does not work, adjust the time delay of the program. Data Structure
BCD_TIME
54 HRS
SUR: BCD2CC
CC_TIME
3F
3E
HR S
SUR: CCX7S
Display
53
MIN
BCD2CC Converter
3D 3C 3B 3A
MIN
52
SEC
SEC
1002x : GM : 03-05
24
Chapter-6.2
Vehicle
CKIT-06A
Taximeter
Mileage
Fare
Wheel
Gear Box
Km
Tk
Wheel
Waiting
Mn
Sensor
K W K TO ISP R ST : Karighar R&D : Bangladesh : CARMET-35LED W-CentreCentre : Bangladesh : Karighar ST ERR TST TST PA Y HRD T R&D
62.1 Introduction The author has already designed, developed, built and field tested taximeters that are really commercially feasible. These taximeters are now on the road of getting in into the market. However, the author wishes that the interested readers should come forward with new ideas of building exciting taximeters having extraordinary features like remote telemetry, graphic display and etc. In the following pages, the author has presented the design concepts (both hardware and software) in modular forms. It is hoped that the readers would work on these modules and convert these into functional objects. At the end, all these modules could be integrated together to realize the Actual Taximeter. The University students may take it as theses/project works. And if so, the author may sometimes arrange a National Competition on Design of Microcontroller Based Digital Taximeter. 62.2 Brief Working Principles of CARMET Karighar R&D Center has, for the 1st time in Bangladesh, successfully designed, developed and prototyped a Metering System for the Taxi/CNG Cabs. The Company has given the name CARMET-35, which stands for Metering System for the Taxi Cars developed in the month of May of the year 2003. The design layout of the CARMET is depicted below in Fig-61.1. The CARMET is built around an 8x51 Microcontroller and an 8279 peripheral controller (Fig15.7). The 8x51 receives status signal of the Wheel (running or not) through a sensor, which is attached with the gearbox of the engine. It then computes the Distance, Fare and Waiting Time/Speed according to some predefined algorithm. The 8279 drive the Digital Fare Meter (DFM), Digital Distance Meter (DDM) and the Digital Wait Meter (DWM). The DFM, DDM and DWM have been built using CC-type 7-segment display devices. The DDM is incremented by 10m and the corresponding increase in the DFM is (for the CNG auto): a. Tk 1.00 for 200m distance traveled or b. Tk 1.00 for 2min waiting time or c. Tk 1.00 for the combination of distance and waiting making an equivalence of 200m.
25
TO PAY
K TST
W TST
W-K ERR
ISP
62.3
1006: GM:02=2005
M1 B+
12V
M5
Fare
Distance
Waiting
Vcc
B-
0V Voltage R egulator
0V
GND
CS/
User Data
p,...,a
A D C
A D C
DR : 2000H CR: 2100H
SL3-SL0
M2
M3
P11 Q2 Q1/ INT0/ T0/
+5V 0V SPulse
DP0-DP5
DP6-DP11
DP12-DP15
Transducer
M8
INT1
IRQ
SL3-SL0
Decoders: 2x138
M9
6MHz
S2-SL0 S0/
Decoders:1x138
S2/
RL2 RL3
Microcontroller : 89S51
HRD W
M10
Keyboard
26
62.4 Hardware Module-1 (Installing One-shot Circuit) Let us build the one-shot circuit of Fig-62.3 on the breadboard. It is left as an exercise for the readers to explore the working principles of the one-shot circuit.
+5V
G F
INT1(P33)
IRQ
Q1 : C828
0V
S peed Pulses
A
+5V
R1=1K 6 C1= 0. 1u 7
D
C2= 1000uF 14
T0(P34)
+5V
R2=3k3
+ 15
11 CLR/ Q1 5 16 Vcc 10 9 K1 8
CLR/ Q2 13
Waiting
2 1
INT0(P32)
P1.1
Q1/ 12
GND
Q2/ 4
GND 0V 8
755x
Figure-62
C3 = 0.1uF
0V
The One-shot Circuit: The package contains two pieces of identical re-triggerable one shots. The schematics and its connection with the transducer and microcontroller are shown in Fig-62.3. The duration of the transducer signal Sig varies with the speed of the vehicle (See Example62.1). To produce the same type of pulse out-of-Sig, the Sig information is pulse-shaped by passing it through the one shot circuit of 1/2Uz. The low-going edge of the signal Sig of the transducer fires the one shot 1/2U1 to produce a pulse of duration 0.15mS (=150uS). The inverted output of 1/2U1 is labeled as speed Pulses and is connected at T0(P34) terminal of the MCU Considering the CNG vehicle, the transducer produces about 1500-1700 pulses for 1km of distance traveled. As long as the wheel is turning, there is always presence of speed pulses at P34-pin. The MCU receives the pulses, calibrate these, computes the fare and then display the fare and the distance. The absence of the Speed Pulses (let us call it WTP) indicates that the wheel of the vehicle is not turning and the MCU must recognize that the Waiting Event has started. Is it always true? Not necessarily! It is true that there will be no speed pulse when the vehicle enters into Waiting State. But the absence of the speed pulse does not necessarily mean that the wheel of the vehicle is not turning. There may be occasions when the vehicle is moving at a very slow speed, and in that case, the occurrence of the speed pulse would also be very rare. Therefore, the event of the absence of the speed pulse cannot be used as an input to the MCU for triggering the Waiting Cycle. The valid waiting state of the vehicle is recognized in the following way: The speed pulse signals are converted to High Level Logic by re-triggering the 2/2U1 one shot by the falling edge of every speed pulse. The width of the Q2 output is chosen in such a way so
27
that the 2/2U1 always receives re-triggering pulses even at the acceptable slowest speed of the vehicle (See Example-62.1). This arrangement allows the MCU to recognize the valid waiting state or wheel turning state by monitoring the Logic State of the status signal at a the port pin, P1.1. If the vehicle moves at a speed, which is lower than the acceptable limit, there will be no speed pulse at the appropriate time to re-trigger the 2/2U1 one shot. As a result, the status signal will drop to Logic Low State and the MCU will be interrupted at the INT0 pin. The MCU will jump to the ISUBINT0 to start with the processing of the waiting cycle, which involves (i) counting of the current waiting time, (ii) fare calculation and updating by combining the current waiting time with the distance traveled (iii) monitoring the end of the waiting time.
Example-62.1: A CNG auto is moving at a speed of 10km/hour. The transducer of this particular CNG produces 1500 WTP for 1km of mileage. (a) Show that the CARMET will not trigger the waiting cycle. (b) Calculate the minimum speed of the CNG at which the waiting cycle of the meter will be activated. Solution: (a) Average WTP/Sec = (1500x10) / (60x60) = 4 WTP pulses. Assuming smooth speed of the CNG, the WTP separation time is = 0.25 S The 1st WTP will trigger the 2/2U1 to assert 1.5S pulse at Q2. The 2nd WTP will re-trigger the 2/2U1 at the elapse of only 0.25S of the 1st Q2 pulse. Because the 2/2U1 is a re-triggerable one shot, the Q2 will begin with a fresh 1.5S pulse. After 0.25S, the 3rd WTP arrives and so on Thus, we see that the Q2 will never drop to low state and the MCU will never execute the waiting cycle. (b) For the MCU to activate the waiting cycle, the Q2 of 2/2Uz must drop to low state. This requires a speed of the CNG, which fails to re-trigger the 2/2U1 at the appropriate time (before the expiry of the 1.5S width of the Q2). Therefore, the time separation between the two successive WTP pulses must be 1.5S. So, WTP/Sec = 0.7. Therefore the CNG speed is : (0.7x60x60) /1500 = 1.68km/hour.
62.5 Hardware Module-2 (Installing Speed Transducer) 1. Collect the speed transducer of Fig-62.4a and connect it with the one-shot circuit of the breadboard as per following specifications:
Transducer Terminals 1 (Red Color) 2 (Green Color) 3 (Black Color)
760
One-shot Terminals A C B
Spindle
+5V
Sig 0V
Shield
760
Apply power to the one-shot circuit. Connect Ch-1 of an oscilloscope at terminal point D and Ch-2 at terminal point E. Turn the spindle of the transducer and check that there appears pulses at D-point. Point-E remains at LH state. 3. Stop turning the spindle. There should not be any pulses at D-point and E-point should assume LL state. The Transducer: It is a low-cost tachometer using hall-effect devices. The shaft of the transducer is mechanically coupled with the shaft of the gearbox of the engine of the vehicle. The constructional structure of the tachometer is shown in Fig-62.4b.
2.
28
62.6 Software Module-1 (p626.asm) Task: Develop program codes, which when executed will produce the following result.
Display Field DP0-DP5 DP6-DP11 DP12-DP15 Name Fare Distance Waiting Value 00.00 0.00 0.00 Comment Initial Fare Initial Distance Initial Waiting
After the execution of p626.asm, let us press the HRD-key. We should see the following readout on the 7Segment display of the trainer.
Display Field DP0-DP5 DP6-DP11 DP12-DP15 Name Fare Distance Waiting Value 12.00 0.00 0.00 Comment Initial Flat Fare Initial Distance Initial Waiting
In the design of any instrument, we need to follow some guidelines, which are: (i) List the all possible input and output variables (ii) List the memory locations, which are used to store all these variables (iii) List the memory locations, which are being used as flags, counters and etc. (iv) And now draw a table of Fig-61.6 what we call Data Structure.
Let us take the help of Figure-A.7 (Apndix-A) and build the following data structure of Fig-62.5.
Tab Loc le 6F
Contents
Rem ark
U19: 8279
BC D SPEED
DP0DP1 1000,100 DP2DP3 1, 10 DP4DP5 1/10,1/100 DP6DP7 1000,100 DP8DP9 1, 10 DPADPB 1/10,1/100 DPCDPD MIN DPEDPF SEC
DP0 DP1 DP2 DP3 DP4 DP5 DP6 DP7 DP8 DP9 DPA DPB DPC DPD DPE DPF
p-a
DP0
DFM
DP5
T4
6D
1 3 8 9
DP6
T3
57 56 55 54 53 52 51 50
DDM
DPB
DFM
2 3 3
DPC
DWM
DPF
DDM
0 3 7
7Segment Display
T2
T5
3F 3E 3D 3C 3B 3A 39 38 37 36 35 34 33 32 31 30 2F
2A
DP0 DP1 DP2 DP3 DP4 DP5 DP6 DP7 DP8 DP9 DPA DPB DDC M IN DDD DPE SEC DPF
SUR10
DWM
SUR11
Fare (Tk)
Wait(Min)
DP0
LCD Panel
Speed(Km /h)
Distance (Km )
T1
19 18
MIN SEC
SCW M
(BCD)
527a : GM : 10-05
SCWM : Software Current Waiting Tim e Meter STWM : Software Total Waiting Tim e M eter STDM : Software Total Distance Meter STFM : Software Total Fare M eter DFM : Digital Fare Meter DDM : Digital Dstance Meter DWM : Digital Waiting Tim e M eter
29
NOP keep polling the keyboard of the trainer If (pressed down key = HRD key) Goto L9 Else Goto L8 L9: Show: 12.00 at the Fare Field of the 7Segment display 0.00 at the distance filed 0.00 at the Waiting Field L10: wait here
62.7 Software Module-2 (p627.asm) [Measuring Distances from the Speed Pulse] Add the following codes at the appropriate places of program p626.asm to bring the following affect in the functioning of the program P627.asm. 1. Let us press 17 pulses pressing the breadboard switch K1, the Distance Field of the 7Segment display would show: 0.01. 2. Apply another set of 17 pulses, the distance meter would show: 0.02 and so on. 3. Apply very speedy pulses from using a high frequency oscillator. 4. Keep counting until the display shows: 9999.99. This would verify that the distanceupdating algorithm is working fine! . . L1: the input pulses are entering to Counter-0 of the MCU. Now let us configure the Counter-0 as follows: a. It will keep counting the speed pulses and at the end of counting 17 (11H) pulses, it will produce a flag named TF0 in the TCON-register of the MCU. b. Keep polling the TF0-bit and when found set, update the distance by 10m. We have learnt previously that a CNG auto produces about 1700 pulses for 1km distance. There fore. There will be 17 pulses for 10m of distance. c. Keep measuring the distance, update it and display it. d. The above method of counting the speed pulses is known as Polling Method. P627b.asm (Measuring Speed Pulse on Interrupt Method) L1: Configure Couter-0 for counting 17 pulses to rollovers from all 1s to 0s. L2: Enable Timer-0/Counter-0 interrupts logic L3: Write codes for ISURTFO (Timer-0/Counter-0 overflow Interrupt) to update the distance. L4: Continue .
30
62.8 Software Module-3 (P628.asm) [Computing Distance Fare and Update] Add codes with program p627.asm so that we observe that: 1. Distance would keep updating by 10m. 2. There will be no change in fare for distance <2.00 km. 3. When the distance just arrives at 2.00 Km, the fare would be change to Tk 13.00. 4. After that for each distance of 200m, the fare would be updated by Tk 1.00. 5. The above program behavior is represented by the following flow chart of Fig-62.6.
1SL2:
fb0=0
1SL3: 1SL7: Y
1 ---> fb0
Mileage=2km ? N 1SL4:
Increase Fare
1SL5:
Return to MLP
526a : GM ; 10-05
Let us convert the flow chart of Fig-62.6 into program instructions and then execute.
ISL2: if (fbo = 0) Goto ISL3 Else Goto ISL6 if ((53H) = 02) Goto ISL7 Else Goto ISL4 Take action as indicated in flow chart Return to MLP See program Codes in the CD See program codes in the CD.
ISL3:
31
62.9 Software Module-4 (P629.asm) [Computing Waiting Time, Waiting Time Fare and Update] Add codes with program p628.asm so that we observe that: 1. Distance would keep updating by 10m. 2. There will be no change for distance <2.00 km. 3. When the distance arrives at about 1.70 Km, disconnect the speed pulse source. 4. The taximeter should immediately enter into Waiting State. The Waiting Time Field would start counting the Waiting Time by 1-sec. 5. Keep waiting until the Waiting Time is 2-Min (Waiting Time Field shows: 2.00). Let us observe that at the elapse of 2-Min waiting time, the fare is update4d by Tk 1.00. The additional Tk 1.00 comes from the fare of 120-sec (2-Min) waiting time @ Ps 50/1-Min. 6. Wait for another 1Min and observe that the fare is updated by Tk 1.00. 7. The readers may notice that Ps 50 is updating the fare for a waiting time of 2-Min. The 2-Min waiting time is not a random or convenient choice rather it is a design criterion, which must be respected to see that the fare for 2-Min waiting time is exactly equal to the fare for 200m. In Software Module-5, we shall see the combined affect of Distance Drive and Waiting Time Drive to update the fare by Tk 1.00. Instruction Codes:
L1: add codes to initialize Timer-1 of the MCU to set the TF1-flag bit of TCON register at the end of every approximately 8.9mS. Why 8.9mS? [
18 XT2
OSC
19 XT1
1/12
f1=921.6KHz
SW2
8BH 8DH
Y1 11.0592 MHz
C1-T1/=0 SW1
TL1 (5-bit)
TH1 (8-bit)
TF1
534c
13-Bit Mode-0
Figure-62.7: Mode-0 Operation of Timer-1 to Generate 8.9mS Time Quanta f1 = 921.6 x 1000 = 921600 Hz. Time duration for each pulse = 1/921600 Sec. Timer-1 will count 213 = 8192 pulses to rollover from all 1s to 0s. Each time, there is a rollover, the TF1-flag bit set. Therefore, time difference between two Tf1-flag bits = 8192x(1/921600) Sec = 0.0088Sec = 8.9mS. ] L2: if (p1.1-bit = LL) Goto Waiting State at L3 Else Goto L2 Start Timer-1 (if time counter = 70H) ; 70H = 112 x 8.9 = 996.8mS 1Sec Goto L5 Else Goto L4 Update Waiting Time by 1Sec ; Reset Time Counter Goto L4
L3: L4:
L5:
32
62.10 1. 2.
Software Module-5 (p6210.asm) [Computing Fare for Combined Affect of Distance and Waiting Time]
Bring necessary changes in the mainline program so that the meter behaves as follows: a. Advance the distance by 1.87 Km and then disconnect the speed pulses. b. The meter has entered into waiting state. Can you say after how long of waiting time, the fare would be updated by Tk 1.00. This is to say that the Fare Field would show: Tk 13.00? Ans: 1Min 18Sec. How? Current Distance covered : 1.870 Km Remaining distance to cover 2km : 0.130 Km = 130m = 13x10m 200m distance charges : Ps 100 10m distance would charge : Ps 5 130m distance would charge : Ps 65 = 13x Ps 5 60 (6x10)-Sec waiting time charges 6-Sec waiting time would charge : Ps 50 : Ps 5
c.
Therefore, the equivalent waiting time for the uncovered 130m is: 13x6 = 78-Sec = 1Min 18Sec. Keep waiting for 1Min 18Sec and we would observe that Tk 1.00 augments the fare filed. This is one of the design criterions that must be implemented while designing a digital taximeter. Nm Software Module-6 (p6211.asm) [Computing Fare for Combined Affect of Waiting Time and Distance]
62.11 1. 2.
Bring necessary changes in the mainline program so that the meter behaves as follows: c. Advance the distance by 1.230 Km and then disconnect the speed pulses. d. The meter has entered into waiting state. Wait for 54Sec and then connect the speed pulse source. Can you say after how much of distance coverage, the fare would be updated by Tk 1.00. Tk 13.00? Ans: 680m. How? Current Distance covered : 1.230 Km Remaining distance to cover 2km : 770m Elapsed waiting time : 54Sec = 9x6 Sec Elapsed waiting time would charge : Ps 45 Ps 5 is charged for : 10m Ps 45 would be charged for : 90m Therefore, the additional distance that has to be covered to make the fare field showing Tk 13.00 is : 770m 90m = 680m!
62.12 1. 2.
Now bring necessary change in the mainline program so that it behaves as follows: a. The DP12-DP15 devices of the display unit are configured to work as Speed Meter with readout as: xxx.x Km/Hr.
33
a.
Apply speed pulses by pressing the switch K1, which is located on the breadboard. We would observe that the DP12-DP15 of the display unit shows some value of the speed in Km/Hr. Keep pressing K1 at a higher rate; we will see that the value of the speed is also changing. b. Apply speed pulses from J10-12 connector, we see that the speed is about: 202.5 Km/Hr. c. Apply speed pulses from J10-13. The speed is about: 405.0 Km/Hr. Instruction Codes: L1: Timer-1 should have been initialized in mainline program to generate 8.9mS time quanta. This time could be used to divide the 10m distances to compute the speed. L2: if (TF0 is set meaning the taxi has covered 10m distance) Compute Speed and display at DP12-DP15 as: xxx.x Km/hr L3: Continue computing distance and display it Speed Measurement Principles: Let us assume that Timer-1 is configured to generate 8.9mS time quanta. To measure speed (Km/Hr), we need to know about time that has elapsed while the taxi traveled 10m distances. Let us also assume that the Timer-1 has generated n number of Time Ticks (TT) during 10m distances. One TT corresponds to 8.9mS time. Now, we may write as:
Speed = 10m/(nxTT) [ 1 TT = (1/f1) x 8192 Sec Refer Fig-61.8 f1 = Y1/12 = 11.0592/12 ] = [[(10/1000) ]x3600 ] / (n xTT) Km/hr = (1/n) x (11059200 x10x3600)/(1000 x 12 x 8192) Km/hr = (10/n) x 405 Km/Hr = 405/(n/10) Km/hr = (405x10)/(n/10) xxx.x.x Km/hr ; Multiply by 10 would allow displaying the speed as having one digit after the decimal point. = 4050/(n/10) = 0FD2H/(n/0AH) ; xxx.x Km/hr
Speed
Implementation: 1. Make arrangement in the program codes to count n 2. Compute n/0AH by calling division SUR13 at 1A00H and SUR14 at 1AA0H.. 3. Compute 0FD2H/(n/0A) by calling SUR13and SUR14. 4. Convert the Binary Speed into BCD by calling SUR15 at: 1B9BH. 5. Display the BCD speed on DP12-DP15 as: xxx.x Km/hr. Now bring necessary change in the program P6212.asm so that DP12-DP15 shows 0.0 Km/hr when the speed pulses are not injected. 62.13 1. 2. Software Module-8 (p6213.asm) [Combined Computation and Display of Speed and Waiting Time]
Now bring necessary change in the mainline so that the meter behaves as follows: a. The DP12-DP15 devices of the display unit are configured to work as Speed Meter with readout as: xxx.x Km/Hr.
34
d. Apply speed pulses by pressing the switch K1, located on the breadboard, we would observe that the DP12-DP15 of the display unit shows some value of the speed in Km/Hr. Keep pressing K1 at a higher rate, we see that the value of the speed is changing. e. Apply speed pulses from J10-12 connector, we see that the speed is about: 202.5 Km/Hr. f. Apply speed pulses from J10-13. The speed is about: 405.0 Km/Hr. g. Disconnect the speed pulse source. Now, the meter should enter into waiting state and counts seconds. The waiting time would appear on DP12-DP15 in the form of: xx.xx. h. Reconnect the speed pulse source. Now the meter should show speed (Km/hr) on DP12DP15 positions. Instruction Codes: L1: if (speed pulse missing) Goto L3 L2: Update distance Compute speed and display at DP12-DP15 L3: Update waiting time and display at DP12-DP15 L4: Goto L1 62.14 Software Module-9 (p6214.asm) [Complete Taximeter based on 89S51 and 8279] Combine together all the software modules/routines so far developed in order to transform the CKIT-06A into a Digital taximeter. The taximeter must comply with the specifications of the following table.
Drive Only Distance Drive. Waiting OFF Result Fare: 13.00 at 2.00 Km Fare: 14.00 at 2.20 Km Fare: 15.00 at 2.40 Km . Fare: 13.00 at 0.00 Km. Waiting :20.00 Fare: 14.00 at 0.00 Km. Waiting: 22.00 Fare: 15.00 at 0.00 Km. Waiting: 23.00 Fare: 13.00 Fare: 14.00 Fare: 15.00 Fare: 13.00 Fare: 14.00 Remarks DP12-DP15 Shows speed (Km/hr)
DP12-DP15 Shows waiting Time Calculation: 55Sec/6=9 9x10 = 90m 02.00 00.09 = 01.91m Calculation; 2.00- 1.75=0.25 km 250/10=25=25x6=150Sec 150Sec 2.30 sec Calculation: 200-50 =150/10=1590Sec 150m Calculation: 18sec/63x10=30m 200m-70m=130m 130m-30m = 100m 270m+100m = 370m
Distance and Waiting Combined - Get waiting: 0.55, distance: 1.91 Km - Get waiting 0.55, distance: 2.11 Km - Get waiting: 0.55, distance: 2.31 Km Waiting and Distance Combined -Get distance: 1.75 Km. Waiting: 2.30 -get distance:1.75, waiting: 4.30 Distance and Waiting Combined -Get distance 2.25 Km, waiting 0.00 -Get distance 2.25 Km, waiting: 1.30 -get distance 2.25Km, waiting:n3.30 Waiting and Distance Combined -get dist: 2.27 - get wait: 0.18 - get dist: 2.37 -Get distance: 2.57 -get dist: 2.57, wait: 2.18
Fare: 14.00 Fare: 14.00 Fare: 15.00 Fare: 16.00 Fare: 17.00
35
1008: GM:02=2005
M1
Voltage Regulator
+12
M5
M6
Microcontroller : 89S51
+9V
Fare
Distance/ Waiting
B+
12V
+5V
+9V
Vcc
P0
0V
M2
Signal Conditioner
Pulse Shaper
SP 0V
M7 Power Driver
Transducer
M3
+5V
M4
Switch
2804
0V
0V
GND
User Data
p,...,a
M8
P30
2003
2003
+5
P1 P2
M10
11.0592 MHz
P35
0V
Functional Descriptions: 1. M1 provides immunity to logic power supply during the electric firing of the engine. 2. 3. 4. 5. 6. 7. 8. M3 minimizes the cross talks between the signal lines and the engine firings. M4 allows the MCU to decide if the car is moving or not. M10 allows the meter to enter into waiting state at the activation of the Hired switch. M5 is a voltage regulator to provide +5V for the logic and +9V for power buffers. M7, M8 are the power buffers and provide good visibility for the 7-segment display devices in the daylight. M9 is the 7-segment type display unit. M2 is an electronic transducer that picks up the speed pulses while the car moves.
36
Pan
Weight
Display
C ost 1 9 9 8. 8 0 Tk 1 9. 9 9 0 Kg 9 9. 9 9 Tk
Keyboard
7 4 1 0 8 5 2
RTE BKS
9 6 3
RST
W eight R ate/Kg
Heartbeat
Power Sw
Figure-63.1: Hypothetical Pictorial View of 8951 Based Digital Weighing Machine (DWM) using CKIT-06A
The goods are placed on the pan. The weight of the goods is displayed on the Weight Filed of the display unit. The display unit is made using segment display devices. The rate (Tk/Kg) of the goods is entered from an interactive keyboard, which is attached with the front panel of the DWM. The rate is displayed on the Rate Field of the display unit. The cost of the goods is displayed on the Cost Field of the display unit. The DWM continuously
i. ii. iii. iv. v. Reads the weight Reads the rate Computes the cost Displays the Weight, Rate and Cost. Blinks the Heartbeat LED ON/OFF to indicate that the DWM is active.
The rate is acquired on interrupt basis. The DWM remains in rate acquisition mode until the 4digit entry for the rate is complete. During rate acquisition period the weight and cost are not updated. At the end of rate entry, the DWM updates the weight, the rate and the cost.
M4 M5
Weight
8051 MCU
We i ght Kg Tk
Rate /Kg
Load Cell
AM P ADC
M1
M2
M3
37
Keyboard
7 8 9 4 5 6 1 2 3 0
RTE BKS RS
KDIC
Scan Codes Scan 8279 Codes
MCU
Data Data
CCCodes
DDIC
Display Data
Total Cost in Tk
DP0 DP5
CCCodes
Data
Rate Data
IRQ
Weight in Kg
DP6 DP10
U19
Weight
Analog
U17
BCD
8051
Data Data Data
RAM
6264 2764 U10 U8
Data
8279
Rate/Kg in Tk
DP12 DP15
4433
Loadcell
LCIC
U2
EPROM
U19
Digital Display
Figure- 63.3: Design Level Hardware Block Diagram of DWM Based on CKIT-06A
Weight
+ Sense (Blue) + Excitation (Green)
+ Output (Red) + Output (White)
Load Cell
Figure-63.4: Load Cell
There are three single point load cells primarily intended for use in weighing scales although they may be used in many other applications. The force applied to the load face of the cell causes a deflection of the body, which is measured by the bridge of four strain gauges. A screened lead, 6-wire system is used or best accuracy. When used for weighing scales the load cell can be filleted with a platform up to the maximum size. The output of the cell is independent of the point through which the load acts. [Courtesy: RS Catalog]
38
Sl. No. 1 2 3
Capacity
Technical Specifications
2 Kg 20 kg 100 kg
a. Total Error : 0.0025% of the rated load b. Recommended Excitation : 5V (10V) c. Output at Rated Load : 2 mV/V 10% d. Zero Return : 0.025% of the Rated Load e. Zero Balance : 5% of Rated Load f. Safe Overload : 150% of the Rated Load g. Ultimate Overload (for failure) : 300% of the Rated Load h. Insulation : >106 ohm i. Output Impedance : 350 3 ohm
6.3.5
Instrumentation Amplifier
+12V
+V2
R7 10k
3 2
1/2 U1 1 + -
R6 10k 2 8
R3 5k 6
- V1
+ 1/1 U1 LM358
1/1 U2 LM358
0V
-12V
323b
R1: 20k
8
+ V2
12 11 +
N/C
6 OF1
+12V
A10
7 OF2 +V
G SS2
20k
4 G SS1 -
INA1 01
-V
G ST2 10
5 G ST1 A20 9
1 (OU T)
CO M
14
13
- V1
R2: 20k
N/C
-12V
0V
323
39
6.3.6
U17
2 10 Vref CLK1
0V
24 Vcc
C17 0.1uF
CO1 C02 7 8
0V
C32 0.1uF (Offset)
U2:8051 U19:8279
DP6
DP7
DP8
DP9
+5V
Rx
R12 External 300k 5k Pot on the Breadboard C31 0.1uF H J8-9 Input 0-2V J8-10 L R 11
11
C34 47uF 3 +
CLK2
Vx
4433
EOC DU OR/
Q3 Q2 Q1 Q0
DS1 DS2 DS3 DS4
14 9 15
23 22 21 20
19 18 17 16
J8
J21 2 3 5 1 2 3 4
1 470k 4 5 6
Vag
0V
R1 R1/C 1 C1
LCD Panel
GND Vee 12 13
C37 0.1uF
GM:648a: 06-04:10-05
-5V
0V
6.3.7
GM:648a: 06-04:10-05
Weight
P32 - P30
RAM
ROM
P17-P10
P23-P20
Load Cell
Amplifier
ADC
Microcontroller
40
6.3.8 Computation Flow Chart for the 89S51 Based Digital weighing Machine
Rate in Tk/Kg.
D
Each 16-Bits Binary
Software Module Subroutine Software Module Software Module Subroutine Subroutine Cost in Tk
Binary-toBCD Converter BCD-toCCcode Converter
CC xfer to Display
Goods
D C
BCD-to-Binary Converter
07CFH 19988001 0130FE21H
Cost:
32-Bits Binary 4-Bytes Common Cathode Codes 06, 6F, 6F, 6F
Cost:
4-Bytes Packed-BCD
4-Bytes Unpacked BCD for Weight Data : 00.00-19.99 Kg. Example: 19.99 Kg. 1000, 1001, 1001, 1001
Weight in Kg.
BCD-toCCcode Converter
Hardware Module
41
6.3.9
L25A:
Make Arificial RETI and Makes the ISURINT0 as an Artificial Main Line Program L24:
Enable Interrupt
fb1= LH ? N L25:
N
REN Cmnd ? Y
Acquire UpBCD Wt: DS1, DS2, DS3, DS4 and save at: 58H, 59H, 5AH, 5BH
L14:
1. Show: _ _ . _ _ at the Rate Field with a Blinking Cursor 2. Set fb1 to LH 3. Init Cursor Position, Digits to Print 4. Enable Interrupt
L23A; Cursor ON/OFF
Obtain Packed BCD Wt from UpBCD Weight and Save at: T5C of Data Structure
L15: SUR
REN Key ?
N L26A:
L18:
SUR BIN2BCD
Print Done ?
L28: Y
Convert BCDRATE, BCDWT and BCDCOST into CCcoded Data and save at T3 of Data Structure. Place Decimal Points at T3
L22:
SUR BCD2CC
Remove Leading Zeros of Cost. Transfer CCdata of T3 into Display RAM of 8279
L23:
HearBeat LED ON/OFF via P3.4 Port Pin
SUR CCX8279
SUR TDELAY
The Product rate (Tk/Kg.) is acquired from the keyboard on interrupt basis in is shown here to the right of Main Line Program. The interrupt ocurs at INT0 pin of the MCU. The vector direction is: KeyPress ---> INT0 -----> 0013H ---> C0F0H ----> ISURINT0. The mail line program is located at C1000H. The MPU reads the rate, the weight and then computes the total cost using EPROM resident subroutins. 294
Figure-63.11 : Data Acquisition/Computation Flow Chart for the Digital Weighing Machine
42
Chapter - 6.4
Microcontroller xx51
RxDP30
MCU AT89C0251
100Hz ZCD
PC5 PC4 PC3
AC
220V AC
TR1
POS1
POS2 POS3
D7-D0 WR/ A CS0/
25mS
25mS
TR2 TR3
L
L
25mS
PIT 8253
POS4
POS5 POS6
25mS
TR4
25mS
25mS
TR5 TR6
L
L
2K EEPROM
64 Byte RAM 64 Byte SFR
PIT 8253
POS7
POS8 POS9
25mS
TR7
25mS
25mS
TR8 TR9
L
L
PIT 8253
25mS
25mS
25mS
POS10
POS11 POS12
D7-D0 WR/ A CS3/
PDEC 74138
CS/
CS7/-CS0/
PIT 8253
25mS
25mS
25mS
PA5
POS13
POS14 POS15
D7-D0 WR/ A CS4/
PIO 8255
D7-D0 WR/ A CS6/
PA4 PA3
PIT 8253
250mS
25mS
50mS
PA2
POS16
POS17 POS18
D7-D0 WR/ A CS5/
PA1 PA0
PIT 8253
MBSD\REMOTE1: GM:01-03
43
8-Bit CPU
P37-P30
4K EEPROM
128 Byes RAM
T-C1/ T-C0/
INT1/ INT0/
RxD TxD
P2
P27-P20
P1
P17-P10
P0
P07-P00
The Atmel Microcontrollers The Atmel Company of the USA has launched a series of microcontroller chips, which offer very cost effective solutions to many industrial control applications. These chips have borrowed the Instruction Set and the CPU from the 8051 of the Intel Company. It is also fully compatible with the Intel 8-Bit peripheral controllers. The following are the commonly used MCUs of the Atmel Company:
a. b. c. d. 892051 89S51 89S52 89S8252 : A 20-pin version with 1 Kbytes EEPROM for program codes. : 4K Code Memory with In-System Programming (ISP) capability. : 8K Code Memory but ISP capability. : 8K Code Memory, 2K Data Memory, ISP capability and SPI Port.
44
89S51 Architecture
89S51
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 P10 Vcc P11 P00-AD0 P12 P01-AD1 P02-AD2 P13 P03-AD3 P14 P15/MOSI P04-AD4 P16/MISO P05-AD5 P17/SC K P06-AD6 RST P07-AD7 P30-RxD EA/-Vpp P31-TxD ALE-PG/ P32-INT0/ PSEN/ P33-IN1/ P27-A15 P34-TC 0/ P26-A14 P35-TC 1/ P25-A13 P36-WR / P24-A12 P37-RD/ P23-A11 XTAL2 P22-A10 XTAL1 P21-A9 GND P20-A8
40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21
698
Y = 6MHz
18 XTAL2
698
19 XTAL1 P37-P30
NC
30 29
ALE PSEN/
17,16,15,14,13,12,11,10
P27-P20 9 RST
28,27,26,25,24,23,22,21
P17-P10
8,7,6,5,4,3,2,1
31
EA/-(Vpp)
40 20
Vcc GND
P07-P00
32,3334,35,36,37,38,39
TxD R xD
10 11
RxD TxD
P1
P17-P10
8,7,6,5,4,3,2,1
External Modem
RST
External Port
13 12 15 14 19
Y = 6MHz
18 31 40 20
17 16
29
28,27,26,25,24,23,22,21
RD/ WR/
PSEN/ A15-A8
+5V
30
32,3334,35,36,37,38,39
ALE
AD7-AD0
699
Figure-A.4: Bus Lines Operated 89C51 Based System Accessing External ROM, RAM and IO Devices
Fig-A.3 is an application of the 89S51, in which all the internal four ports consisting of 32 (4x8) IO lines have been used as simple IO lines to accomplish data transfer operations with the peripheral devices. Fig-A.4 depicts a system in which the MCU is accessing external Program Memory, Data Memory, Memory-mapped Port and also supports the functions of Interrupt, Counting, Serial IO and Parallel IO.
45
M1
M2
divide by 12
8-BIt CPU
M3
1-BIt CPU
M4
In Sys. Prog. Interface
11.0592 MHz
M6
M7
SPI Interface
M5 8-BIT
Accum ulator (A)
M8
Rx, Tx
TC0-2
INT0-1
M12
M13
M13
M9
Code EEPROM (FLASH) 0000 - 1FFF
Security Bit
M10
Data EEPROM 0000 - 7FFF
Security Bit
M11
SFR (80-FF) Upp RAM (80-FF) for 89X52 only Lower Block of RAM (00-7F)
Exter. Interrupt
M14
M15
Addree Bus Interface
P00-P07
Port-0
A00-A15
M16
M17
P10-P17
Port-1
Data Buffer
D0-D7
M18
M19
Write Control Logic
P20-P27
Port-2
WR/
M20
M21
Read Control Logic
RD/ PSEN/
P30-P37
Port-3
783 : GM : 1-11-05
46
Processing Module-1
Internal R AM FF
R egister Set
B*
Processing Module-2
F0 E0
xx52
80 7F
AC C * -
Port-1 Latches P17 P17 P15 P14 P13 P12 P11 P10
Port-2 Latches P27 P26 P25 P24 P23 P22 P21 P20 A15 A14 A13 A12 A11 A10 A9 A8
Port-0 Latches
16
P36 WR/
15
P35 C 1/
B0
A8
14
P34 C 0/
A0
(8)
91
13
P33 INT1/
90
8D 8C 8B 8A
12
P32
TH0
0000
INT0/
TL1 TL0
11
TM OD 89 TC ON
(8)
P31 TxD
88
PC ON* 87
DP1H DP1L
DP0H DP0L
85 84
83
10
P30 R xD
82
81
80
SP
0000
P0*
29 30
PSEN/
PC = 16-Bit
A15-A00
ALE
MOVX @DPTR , A: DPTR = 16-Bit
A15-A00
A15-A08 by P2 A7-A0
47
SP
70 6F 6E 6D 6C 6B 58 57
Key Sccan C ode C TP (C ursor Type) NPD (Digits Printd left of C urs C R P (C urs Pos)/ PR P (Print Pos)
Scratch pad Mem ory Space
F1 F0 EF
F7
F0
NOT AC C ESSIBLE
DP0DP1
E1 E0 DF
E7
E0
AC C
NOT AC C ESSIBLE
50 4F
DPEDPF DP0
D1 D0 D7 CF
NOT AC C ESSIBLE
D0
PSW
CD CC CB CA C9 C8
40 3F
DPF DP0
B9 B8 BF B7 B8
IP
B1 B0 B7 AF
NOT AC C ESSIBLE
B0
P3
30 2F
27
20 1F 18 17 10 0F 08 07 00
CC CC CC CC 7F 7E 77 6F 67 5F 57 4F 47 3F 37 2F 27 1F 17 1F 07 06
05
04
03
Bank-3
Bank-2 Bank-1
Bank-0
A9 A8 AF A7
NOT AC C ESSIBLE
A8
IE
DPF
A1 A0 A7 9F
NOT AC C ESSIBLE
A0
P2
9A 99 98
NOT AC C ESSIBLE
98
9F
SBUF SC ON
91 - 97
NOT AC C ESSIBLE
97
Flag Table
90 8E - 8F 8D 8C 8B 8A 89 88 87 86 85 84 83 82 81 80
NOT AC C ESSIBLE
90
P1
87
NOT AC C ESSIBLE
88
87
80
48
8952 only
761
49