Upload
mr-lb-lee
View
220
Download
0
Embed Size (px)
Citation preview
8/8/2019 Digital Name Card - micro processor project
1/38
8/8/2019 Digital Name Card - micro processor project
2/38
2
Table of Contents
Abstract: .................................................................................................................................................................... 3
Introduction: ............................................................................................................................................................. 3
Principles of operation: .............................................................................................................................................. 4
Setup Instructions: ..................................................................................................................................................... 4
Operating Instructions: .............................................................................................................................................. 5
Hardware: ................................................................................................................................................................. 5
Hardware Summary: .............................................................................................................................................. 5
Hardware Schematic: ............................................................................................................................................. 6
Hardware Description: ........................................................................................................................................... 6
Timing Diagrams ................................................................................................................................................ 7
PCB Layout ......................................................................................................................................................... 9
Software: ................................................................................................................................................................... 9
Software Summary ................................................................................................................................................ 9
Start up & Initialization: ....................................................................................................................................10
Main Menu: ......................................................................................................................................................11
Display Info: ......................................................................................................................................................11
Contact Book: ...................................................................................................................................................12
Screen Saver & the Graphical Animation ...........................................................................................................13IR Communication and Transmission Protocol ...................................................................................................14
Conclusion and Evaluation: .......................................................................................................................................17
APPENDIX A [Additional Illustrations] .......................................................................................................................18
APPENDIX B [Source Code].......................................................................................................................................20
8/8/2019 Digital Name Card - micro processor project
3/38
3
Abstract:
This report presents the design and implementation of a novel electronic name card device that makes use
of an 80XX microprocessor emulator. In addition of a micro processor, this device implements the use of a 4 level
gray-scale graphical LCD, a IR transceiver module, as well as a FRAM external memory component that allows non-
volatile data storage of up to 1000+ contact users. As a whole, the system has been oriented towards meeting three
specific purposes; Contact storage/browsing, Contact information exchange, and Innovative Presentation of
Credentials.
Introduction:
The aim of this project is to digitize the paper based name card on a standalone system controlled by a
single micro controller. The project will be geared toward meeting four requirements on functionality; presenting
ones personal information, sending and receiving contact data, presenting a visually attractive screen saver, and
present a contact book that allows users to browse though their stored contacts. We will be using a graphical LCD
display by TOPWAY that allows a 128 x 96 pixel resolution each allowing a 4 level gray scale state. In addition we will
make use of a 24MHz 8xC51 with 4K ROM. Each function will be handled separately in the software domain with a
simple 3 button user interface that will allow of simple and efficient navigation. To allow the device user to save new
users we will use non-volatile external memory space that should efficiently store each users contact package as a
stack which can easily be addressed by the contact book function. Another important aspect of this project is the
protocol used for the transmission of IR data signals between two devices that allow for reliable data transmission
without being prone to error. Each of the before mentioned aspects will be carefully considered in both hardware
and software design and we will aim for a design that is optimal in minimized hardware resources (cost) and
maximized in functionality (value).
The basis of our system consists of a main menu platform that will run after system initialization and allow
simply handle the user interaction to choose what kind of task should be scheduled next. From this platform we will
call functions that will run and after completion will return to its original state waiting for the user to queue the next
processing task. This assures us that the RAM data segment will not get corrupt easily since it avoids the nesting of
multiple functions and therefore allows one to dedicate RAM to a particular function.
The proposed platform is a very generic and simple approach to user interfaces; Present the User with
options, wait for a selection, continue in accordance to selection. In principle this easily allows for a top down
method and should allow us to design each function independently which will improve out efficiency by allowingmembers to work on multiple functions simultaneously without conflict given that the data structure is well
organized and each program has well defined dedicated memory spaces that cannot be altered during the execution
of that program. The trade off by simplifying the design in such an extent is that some program functionality might
be duplicated in different forms. For example one function requires a string to be printed from the ROM while
another function requires a string to be printed from the RAM, clearly both programs will almost implement the
same functionality but because of the independent development it will result in near duplication of code
8/8/2019 Digital Name Card - micro processor project
4/38
4
fortunately we prefer swift development over high quality source code since it will allow us to implement much
more functionality in a limited period of time.
Principles of operation:
The device operation is very simplistic from a user point of view. We simply on start up procedure and 4
states in which the user can interact with the device after power on. Each state is intuitive and listed below
together with a brief description
1. Start up - The start and welcome message will be display every time the system restarts.2. Main menu mode - The main menu includes the 4 major selections, display info, infrared, screen saver
and contact book. After the welcome message or transmission, the program will return to main menu.
3. Screen saver mode - This mode will display the screen saver animations.4. Infrared transmission mode - Under this mode, the user can select to send user contact information or
receive contact information by interrupt.
5. Contact Book mode This will allow the user to browse all stored contacts and view further details afterselection
Figure 1: Operational Flowchart of E-Card System
Setup Instructions:
The system needs three voltage source, 5V, 3.1V and -5V.
1. Connect three grounds to a common one.2. Connect 5V to 8051 port 0 and VDD of external memory.3. Connect 3.1V to VDD of LCD.4. Connect -5V to VDD of op-amps between infrared transceiver and 8051.5. Set mode of emulator to 8X51(4K ROM), Internal Clock 24MHz.6. Simply runs the program and use buttons to select and confirm your actions.
8/8/2019 Digital Name Card - micro processor project
5/38
5
Operating Instructions:
When LCD is displaying Main Menu, use buttons to move arrow up and down, and confirm your selection.
In display info mode, press enter to return to main menu.
In infrared mode, use buttons to move the arrow to select and confirm a contact to transmit.
In screen saver mode, if you want to return to main menu, simply press enter.
In contact book mode, after all names are loaded and shown on the LCD, move the arrow, with the help of
buttons, to select and confirm a particular contact in which you want to look in detail. After all information has been
shown, press enter to return to main menu.
If an interrupt is detected, which means someone is sending information through the infrared port to your device,
you just choose whether to accept or decline the users contact information by pushing buttons. The program will
automatically returns to the main menu after done with transmission.
Hardware:
Hardware Summary:
Micro Controller: - 8051
External Memory: - RAMTRON FM1808-70-P
Graphical LCD: - TOPWAY LM9033a
IR Transceiver: - TL071CP [OPAMP]
Buffer Circuit: - 2N3904 [BJT]
Pull up Resistor: - 5K
8/8/2019 Digital Name Card - micro processor project
6/38
6
Hardware Schematic:
Figure 2: Detailed Hardware Schematic
Hardware Description:
As shown in figure 1, the finalized device hardware design consists of 3 main aspects with the micro
controller centered as the control & data signal hub. The simplest hardware aspect is the direct pin to pin
connection from the 8051 to the RAMTRON FM1808-70-P. This connection is considerably net list intensive. We
could have used a D-Latch to alleviate this issue but since each component was used non-concurrently there was no
necessity to up free pins and we simply joined the high-byte FRAM address bus and LCD data bus as an alternative to
the addition of such a D Latch. In addition, since LCDs normally operate under relatively low voltage conditions wehad to make us of a step-down voltage buffer to interface the 8051 5V output pins to the 3V input pins of the LCD
module. Fortunately, we resolved this issue with the use of a BJT and a resistor since we deliberately did not make
use of the read - status function of the LCD such that the connection is one directional. Given that the load resistor
on the buffer is large enough this will also allow the BJT to reject the noise signals from the GND node as well as the
VDD node
Figure 3: Illustrated Schematic of the Hardware system layout Figure 4: Schematic of the voltage buffer
8/8/2019 Digital Name Card - micro processor project
7/38
The more hardware involved aspect of this project was with respect to designing the IR transceiver. As
shown in FIG & FIG the IR transceiver consists of two individual OPAMP circuits that allow for half and full duplex IR
communication. Since this design uses a near IR (960nm) LED that is driven by a single stage inverting OPAMP. In
comparison the receiver module uses a near IR sensitive LDR that consists of a cascaded inverting and non-inverting
OPAMP. The two stage OPAMP circuit was necessary because the passive LDR has a very large resistance such that
and loading capacitance on the input amplifier has a very slow temporal response if the pull down resistor is not
made considerably small such that high switching speeds may be attained. Using a small pull down resister of course
degenerates the input signal from the LDR and thus requires the additional amplification stage. The pull down
resistor was a variable resistor so that we my later fine-tune the tradeoff between low signal degeneration or high
switching speed. Clearly inverting amplifiers were used so that the passive high state of the serial port is translated
to the passive low or no light state on the IR port which as results allows for better SNR. The OPAMP used was a
OP074 component which we connected to a +5 V and -5V voltage source but as result one also had to implement a
positive half wave rectifier circuit to protect the 8051 from negative voltage inputs. For convenience we simply used
the same voltage buffer circuit as the LCD set-up with its voltage source connected to 5V.
Figure 5: Schematic of the LED Driver Circuit Figure 6: Schematic of the IR Receiver Circuit
Timing Diagrams
Figure 7: LCD Display - LM9033a
8/8/2019 Digital Name Card - micro processor project
8/38
8
Figure 8: External Memory - RAMTRON
Figure 9: Table of Write Parameters
Figure 10:External Memory - RAMTRON
8/8/2019 Digital Name Card - micro processor project
9/38
9
Figure 11: Table of Read parameters
PCB Layout
Figure 12: Hardware PCB layout
Software:
Software Summary
Interrupt Vector & Sequence
Timer 0 : Serial Time Out Interrupt
Serial : Serial SBUF interrupt
S_TIMER: main menu return sequence after timeout
S_RCV: IR contact data reception sequence
8/8/2019 Digital Name Card - micro processor project
10/38
10
Main Code Segments
Main: Start-up Sequence
MAIN_MENU: Han
Reset: LCD Reset
LCD_INIT: LCD Initialization
BLACK: LCD Clear Screen
SND_IR: IR send data sequence
S_SCS: Prompt Send success
S_FAIL: Prompt Send failed
INS: LCD write a instruction
DTA: LCD write a data
DEFINE_USR: Loads user into RAM from ROM
IR_FRAM: Saves received user to FRAM
LD_USR: Loads selected user from FRAM
MEMORY_READ: Reads a single byte from FRAM
MEMORY_WRITE: Writes a single byte from FRAM
NMCARD: Prints out user data that is stored in ROM
A_INIT: Graphical animation sequence
ARRAY_GEN: gray scale Byte generation
WRT_TRACY: Prints a 3 page string
WRT_IN_ONE_PAGE: Prints a 1 page string
CONTACT_BOOK: Contact Book sequence
CONTACT_BOOK_PERSON: loads user data and prints it
START_MENU: Start Menu I/O handler
INFRARED_CONFIRM: confirm save User I/O handler
ROM Stored Data Tables:
PTABLE: 64 byte approximation of a sine function
USR: Stored the users animation scroll name
LETTER_TABLE: Stores pictographic ASCII character information
USR_DEFINED: Stores main users contact info (name, phone, email, logo)
STR_SND: Stores a STRING
STR_SC: Stores a STRING
STR_FL: Stores a STRING
Software Description listed by function
Start up & Initialization:
The Startup sequence makes use of the LCD screen and the LETTER_TABLE which is described earlier. As the
program starts, initialization of stack pointer and variable definition will be executed. For demo use, we predefine
three users, including their names, email addresses, phone numbers and personalized icons, to store into the externa
memory so that we can show the contact book immediately after start sequence is done. The LCD_INIT function will
send a sequence of instructions, which refers to the data sheet, to LCD for initialization. A BLACK function will be
called to clear the screen and then program reaches Main_menu.
Figure 13: Flow Chart of startup sequence
8/8/2019 Digital Name Card - micro processor project
11/38
1
Main Menu:
Main Menu is more or less an idle state which listens to users input through buttons as well as waiting for
interrupt from the serial communication channel. The Start_Menu function displays four options, including Display
Info which shows basic information of products handler on LCD, Infrared which enters contact book, confirms
users will and sends out a particular contacts information through infrared port, Screen Saver which runs an
interesting animation and will be introduced later and Contact Book which make effective use of an fast and non-
volatile external memory as an folder to store other s contact details. An arrow is placed before the first option,
waiting for pushes over buttons. As long as enter button is pressed, the program reads the arrows position, does
an appropriate call. Meanwhile, if any interrupt from serial communication is detected, program will jump to the
interrupt vector to handle the information.
Figure 14: Flow Chart of Main Menu Program
Display Info:
This function is done by NMCARD function. This function is relatively simple since it makes use of
WRT_IN_ONE_PAGE function, which will be introduced later. Basically when entering the main menu, the program
will load a predefined user from ROM (USR_DEFINED1) to RAM (30H to 66H) then call WRT_IN_ONE_PAGE function
to display the information on the LCD.
Figure 15: Flow Chart of Show ID program
WRT_IN_ONE_PAGE: this function, which takes the row position, column position, start byte address, length of string
and a size indicator (bit F0) as input and output a set of instruction and data to the LCD so as to display character
8/8/2019 Digital Name Card - micro processor project
12/38
1
onto screen, is the most frequently function that being called in the whole program. Due to the restriction of the LCD
module, we, at the very beginning, defined a table (
LETTER_TABLE) to draw every character and some special symbols (@. And etc.) The WRT_IN_ONE_PAGE function
first makes use of TRANSLATE_COLUMN_POINTER function to translate a column pointer into two instructions and
then send to the LCD. After setting the position, the function reads an ASCII code from the starting byte address andcalls MATCH_OFFSET to set the relative offset in the LETTER_TABLE.
Finally, WRT_IN_ONE_PAGE_ONE_LETTER function does some calculations to store the responding value in A and
send to the LCD module. This will display one single character at the desired position with a user-defined size (bit F0)
The function decrements string length and loop until a complete string is shown on the LCD.
Contact Book:
The contact book function was implemented for users to store and view other peoples information. This
function mainly makes use of 8051s parallel data bus and the high speed of a FRAM which was produced by
RAMTRON International.
Figure 16: Flow Chart of Contact Book Program
At the beginning of the CONTACT_BOOK function, the program will read the very first byte from the FRAM,
which indicates the number of current contacts in the contact book, then set a memory space 21H to loop through
the procedure to load all users names.
The function CONTACT_BOOK_DISPLAY will display a list of current users in the contact book. Basically itfollows the protocol for storing each user (i.e. first byte indicating length of name etc.), and display each users name
with the help of WRT_IN_ONE_PAGE function. Each time when it finishes displaying ones name, it will add the
pointer, which is the data pointer inside 8051, to the start of next contact.
8/8/2019 Digital Name Card - micro processor project
13/38
1
Up to here, an arrow will point to the first person in the contact book. The user is allowed make a selection
by pushing the buttons. This procedure is simply implemented by polling technique which is the same as in the main
menu.
After confirming users selection, CONTACT_BOOK_PERSON function will display the persons information. It
first moves the FRAM pointer to the right position and then loads the 54 bytes into the RAM. Lastly it calls NMCARDfunction to display the particular persons information.
Screen Saver & the Graphical Animation
The screen saver mode that was implemented on this name card system makes use of the 8051s simple and
rapid computational power and the gray scale functionality of the graphical LCD. Although one can only display 4
shades of tone on the lm9300a LCD we were able to implement interesting visual effect by using a single two-
dimensional sine function. Due to our constraint on quick memory access we decided to let an algorithm generate a
picture frame on the fly instead of storing the frame in the external or internal memory allowing a much more
dynamic picture that it not constrained to its resolution as well as achieving much higher frame rates. The animation
(SEE A_INIT) consists of 32 unique frames in which the program loops though back and forth effectively looping a 64
frame moving picture. Each frame consists of 128 by 56 pixels that are calculated with dependence on the pixel (X &
Y) position as well as the current frame number. By simple scaling and manipulation of these three variables we can
formulate a function that manipulates the offset of a data pointer which points to 64byte stack that holds a sine
approximation. Using the resulting sine value we can determine which shade of gray the particular pixel is. Iterating
this algorithm across the LCD screen per frame created the following effect.
Figure 17: illustration of Animation Sequence
The complete program that handles this algorithm A_INIT consists of a initialization followed by 3 nested loops;
A_LOOP, A_LOOP1, and A_LOOP2. Intuitively each loop handles one of the before mentioned variables; Frame
number, page position, and column position respectively. These loops simple handle the current pixel variable states
in specified registers as wells as readjusting the LCD DRAM pointer once a loop is initialized. Within these loops there
exists a function called ARRAY_GEN. This function is necessary because LCD reads two bytes of information per
write instruction which corresponds to writing a whole column on a specific page in 4-level gray scale per write data
function. As a result one must pre calculate these two bytes before we call the function. We note here that this
function make use of the two bit addressable registers at location 20H & 21H to temporarily shift the relevant pixel
information in one by one.
8/8/2019 Digital Name Card - micro processor project
14/38
1
As shown above we also implemented a roll over text (see WRITE_STRING) which makes effective use of the
function WRITE_TRACY and excellent use of the carry flag to detect a roll over letter case. The letter is printed one
by one with dependence on a column variable which depends on the frame number and a certain off set which of
course depends on the characters order which ranges from 1st up to 5th. It is advised however that the 5th character
a space or blank such that there is a separation between the end and beginning of the string. Intuitively, after the
completion of drawing a particular frame, the system checks the status of the return button allowing the user to
return to the main menu when pressing the return button.
Figure 18: Flow Chart of Animation Program
IR Communication and Transmission Protocol
We implemented the infrared communication protocol based on the situation of the hardware. The protocol include
2 parts, the transmission and the reception, respectively. These 2 parts follow some matched procedures, like the
echoing and the double send or receive for error check, etc.
8/8/2019 Digital Name Card - micro processor project
15/38
1
Figure 19: Flow Chart of IR reception protocol
First we look at the sending, i.e. the method SND_IR, its jumped by an external interrupt of selecting the function
of infrared in the main menu and after choosing a right person to send. A confirms message will be asked to
confirm send, only yes will start the sending procedure and sending protocol. On start sending, the sender first
initializes a silence check to see if the infrared channel is idle, which enables REN and done by the loops of IR_LP1
and IR_LP2. If the SBUF is not empty, meaning theres other client sending information, then the program will jump
to a S_FAIL handler, implying a sending failure. Otherwise, the sender will send out an echo message with the
content AA (in the method ECO) when the channel is deemed idle. It then will wait for an echo back with the
same content of AA. If the sender doesnt receive the echo message back, it will keep sending echo. On receiving a
echo message, the sender will go to E_PAS and check if its the right echo message. If the message isnt AA, it wil
go to S_FL gain. Otherwise it will then send the contact information of the selected person twice. The contact
information is fixed as 54 bytes, with the three fields of 18 bytes, for name and phone number, logo, email,respectively. The reason we choose fixed length of data packages is first, its easy to handle, second, for variable size
of packages, both sides needs to check the size and the transmission procedure will not be fluent. Being not influent
in the transmission, the communications needs more checking and will introduce more noise, thus increases the erro
rate. As such, we chose to use the fixed data packages size. Finally after transmission, itll display the message as
DONE implying a successful transmission of the selected contact.
8/8/2019 Digital Name Card - micro processor project
16/38
1
Figure 20: Flow Chart of IR Transmission Protocol
As mentioned above, the receiving procedure and protocol is similarly matched the sending part. Its implemented in
the method RCV_IR, included in the serial interrupt vector, showing that the serial reception is triggered by serial
interrupt of the RI flag, and this interrupt is only enabled in the main menu, which represents the idle state. On
receiving the serial interrupt and confirmed that its the RI, the receiver will clear the flag and jump to method
S_RCV, checking if the received package is the echo message AA first. If not, then the program will simply return
from this interrupt mode and back to idle state in the main menu, waiting for further instructions or interrupts.
Otherwise, itll disable the serial interrupt and start sending an echo AA back to the sender. Meanwhile, the
receiver will also start a timer for the timeout, in case it waits longer than 65.5ms and didnt get the echo back, itll
simply timeout and jump to an error handler (S_timer). But if the receiver gets the echo message back, then itll
prepare the start position and receive the first pack of the contact information (in RCV_USR), which includes 54
bytes as mentioned above. Itll store in the RAM while receiving, and start to receive the same pack of information
for the second time. In the second receiving, the receiver will first receive the package will check with the original
reception (CHK_USR method), if the second reception has any error with exceptions from the first reception, the
receiving program will jump to error handler S_ERR, which handles the error by re-enabling serial interrupt and
stopping the timer. Otherwise, the receiver will go on checking further errors, and if overall errorless, then itll jump
to INFRARED_INTO_FRAM, which stores the received contact information to the contact book stored in the
external RAM.
8/8/2019 Digital Name Card - micro processor project
17/38
1
Figure 21: Flow Chart of Timer 0 Interrupt Procedure
Conclusion and Evaluation:
The finalized Electronic Name Card design successfully met all our initial expectations and we were able to
implement an efficient and stable system. We found that even though our source code was not optimized to its full
extent the operation of the device was still very smooth and even the animation performed beyond our expectation
In addition we succeeded in wirelessly sending packages from one device to another with nearly 100% success rate.
For future improvements I would make an attempt to optimize the source code by unifying some of the
subprograms into a single general function that can be reused in multiple ways. This should increase programming
complexity but significantly reduce the code segment length. I would also like to include some sort of additional
notification when some ones contact information is received and the system prompt the user to save the data like a
buzzer sound for example. In addition I would like to allow the user to also disable the serial reception of other
peoples contact data with the use of some kind of switch so that one could ignore another person persistently trying
to send their contact info.
A more ambitions though would be to use a color screen instead of the gray scale LCD that is used in this
project to make the presentation even more appealing without necessarily increasing program complexity. This
would make the user interface much more capable to engage more complex functionality as well as make the
animation a much more interesting. As closing remark one may also like to standardize the contact information
package for future integration instead of using our developed protocol. An example would be the vCARD format that
is nowadays commonly used for the transmission of such data among mobile devices.
8/8/2019 Digital Name Card - micro processor project
18/38
1
APPENDIX A [Additional Illustrations]
Figure 22: Group Photo
Figure 1: Operational Flowchart of E-Card System .......................................................................................................
Figure 2: Detailed Hardware Schematic .......................................................................................................................
Figure 3: Illustrated Schematic of the Hardware system layout ....................................................................................Figure 4: Schematic of the voltage buffer .....................................................................................................................
Figure 5: Schematic of the LED Driver Circuit ...............................................................................................................
Figure 6: Schematic of the IR Receiver Circuit ..............................................................................................................
Figure 7: LCD Display - LM9033a ..................................................................................................................................
Figure 8: External Memory - RAMTRON .......................................................................................................................
Figure 9: Table of Write Parameters ............................................................................................................................
8/8/2019 Digital Name Card - micro processor project
19/38
1
Figure 10:External Memory - RAMTRON ......................................................................................................................
Figure 11: Table of Read parameters............................................................................................................................
Figure 12: Hardware PCB layout ...................................................................................................................................
Figure 13: Flow Chart of startup sequence ................................................................................................................. 1
Figure 14: Flow Chart of Main Menu Program ............................................................................................................ 1
Figure 15: Flow Chart of Show ID program ................................................................................................................. 1
Figure 16: Flow Chart of Contact Book Program ......................................................................................................... 1
Figure 17: illustration of Animation Sequence ............................................................................................................ 1
Figure 18: Flow Chart of Animation Program.............................................................................................................. 1
Figure 19: Flow Chart of IR reception protocol ........................................................................................................... 1
Figure 20: Flow Chart of IR Transmission Protocol ...................................................................................................... 1
Figure 21: Flow Chart of Timer 0 Interrupt Procedure ................................................................................................ 1
Figure 22: Group Photo .............................................................................................................................................. 1
8/8/2019 Digital Name Card - micro processor project
20/38
2
APPENDIX B [Source Code]
ORG 0000H
SJMP MAIN
;-------------------------------------------------------------------------------
ORG 0018H
CLR TF0
CLR TR0
LJMP S_TIMER
ORG 0023H
RCV_IR: CLR RI
LJMP S_RCV
;-------------------------------------------------------------------------------
;18H
STR_START EQU 2EH ;THE MEMORY POINTER OF THE FIRST
CHARACTER
STR_LEN EQU 2FH ;THE STRING LENGTH
OFFSET EQU 1AH
LCD_ACCESS EQU P3.5
ORG 0028H
CLR TI
RETI
;p1.0 register select: 1 for data, 2 for instruction
;\ serial clock
;p1.2 serial data
; reset 1 for normal running, 0 for initialization
ORG 0030H
;18H IS THE ROW POINTER
;19H IS THE COLUMN POINTER
MAIN: MOV SP,#066H ;Handles 32 nested Process calls
MOV IP,#00000010B ;set timer0 priority to 1
ANL PCON,#01111111B
MOV SCON,#01010000B ;Bits per Second: 9600, bit/s
MOV TH1,#0FDH ;TH1=-3
MOV TL1,#0FDH
SETB TR1 ;enable timer1
MOV TMOD,#00100001B ;timer1 and timer0 for
timeout
SETB ET0
MOV P0,#00H
MOV P1,#0FFH
;Clear IO pins
MOV P2,#0FFH
; CLR LCD_ACCESS
SETB CE
CALL Reset
CALL LCD_INIT
CALL BLACK
CALL MEMORY_TEST
;CALL DEFINE_USR
;JMP SND_IR
;JMP $
MAIN_MENU:
SETB ES
SETB EA
CALL START_MENU
;----------------
CALL DEFINE_USR
CALL BLACK
CLR ES
MOV R0,18H
CJNE R0, #0B8H, SELECTION_NMCARD
;CLR LCD_ACCESS
SETB ES
JMP A_INIT
SELECTION_NMCARD:
CJNE R0, #0B4H, SELECTION_INFRARED
;CLR LCD_ACCESS
CALL DEFINE_USR
CALL BLACK
CALL NMCARD
SJMP MAIN_MENU
SELECTION_INFRARED :
CJNE R0, #0B6H, SELECTION_CTCBOOK
CLR 6FH
CALL CONTACT_BOOK
JMP SND_IR
SJMP MAIN_MENU
SELECTION_CTCBOOK:
SETB 6FH
CALL CONTACT_BOOK
SJMP MAIN_MENU
;----------------
DONE: SJMP DONE
S_TIMER:
POP ACC
POP ACC
JB 7Eh, SND_RCV
MOV DPTR, #S_ERR
PUSH DPL
PUSH DPH
RETI
SND_RCV:
8/8/2019 Digital Name Card - micro processor project
21/38
2
MOV DPTR, #S_FL
PUSH DPL
PUSH DPH
RETI
Reset:
CLR P3.7
CALL DELAY
SETB P3.7
CALL DELAY
CLR P0.2
RET
LCD_INIT:
MOV A, #048H
CALL INS
MOV A, #060H
CALL INS
MOV A, #0A1H
CALL INS
MOV A, #0C8H
CALL INS
MOV A, #044H
CALL INS
MOV A, #010H
CALL INS
MOV A, #040H
CALL INS
MOV A, #000H
CALL INS
MOV A, #0ABH
CALL INS
MOV A, #066H
CALL INS
MOV A, #027HCALL INS
MOV A, #081H
CALL INS
MOV A, #020H
CALL INS
MOV A, #054H
CALL INS
MOV A, #093H
CALL INS
MOV A, #088H
CALL INS
MOV A, #000HCALL INS
MOV A, #089H
CALL INS
MOV A, #000H
CALL INS
MOV A, #08AH
CALL INS
MOV A, #088H
CALL INS
MOV A, #08BH
CALL INS
MOV A, #088H
CALL INS
MOV A, #08CH
CALL INS
MOV A, #0BBH
CALL INS
MOV A, #08DH
CALL INS
MOV A, #0BBH
CALL INS
MOV A, #08EH
CALL INS
MOV A, #0EEH
CALL INS
MOV A, #08FH
CALL INS
MOV A, #0EEH
CALL INS
MOV A, #02CH
CALL INS
CALL DELAY
MOV A, #02EH
CALL INS
CALL DELAY
MOV A, #02FH
CALL INS
CALL DELAY
mov a, #10100010b
call ins
call delayMOV A, #0AFH
CALL INS
CALL DELAY
CALL BLACK
CALL START_MESSAGE
RET
BLACK:
MOV R1,#010110000b
MOV R2,#000010000b
MOV R3,#000000000b
MOV R6, #0FFH
MOV R7, #12SCRN:
CALL WRT
INC R1
; INC R6
DJNZ R7, SCRN
RET
WRT:
MOV A,R1
8/8/2019 Digital Name Card - micro processor project
22/38
2
CALL INS
MOV A,R2
CALL INS
MOV A,R3
CALL INS
MOV R4,#256
BL1:
MOV A, R6
;CPL A
;MOV R6, A
CALL DTA
DJNZ R4, BL1
RET
S_RCV:
MOV A, SBUF
CJNE A, #0AAH, S_RTI
CLR ES
CLR 7EH
MOV SBUF, #0AAH ; ECO
JNB TI, $
CLR TI
JNB RI, $
CLR RI
MOV TL0,#0
MOV TH0,#0
SETB TR0
MOV B, #53
MOV R1, #30H
RCV_USR:
JNB RI, $
CLR RI
MOV @R1, SBUF
INC R1DJNZ B, RCV_USR
MOV TH0,#0
MOV TL0,#0
MOV B, #53
MOV R1, #30H
CHK_USR:
JNB RI, $
CLR RI
MOV A, @R1
CJNE A, 99H, S_ERR
INC R1
DJNZ B, CHK_USRCLR TR0
JMP INFRARED_INTO_FRAM
S_ERR:
SETB ES
CLR TR0
S_RTI: RETI
SND_IR:
CLR ES
MOV 20H, SBUF
MOV R0, #0FFH
IR_LP1: MOV B, #0FFH
IR_LP2: MOV A, SBUF
CJNE A,20H, S_FL
DJNZ B, IR_LP2
DJNZ R0, IR_LP1
MOV TL0,#0
MOV TH0,#0
SETB TR0
SETB 7EH
ECO: MOV SBUF, #0AAH ; ECO
JNB TI, $
CLR TI
MOV B, #080H
DJNZ B, $
JB RI, E_PAS
JMP ECO
E_PAS:
CLR TR0
CLR RI
MOV A,SBUF
CJNE A, 20H, S_ECO
MOV SBUF, #0AAH
JNB TI, $
CLR TI
SJMP S_NXT
S_ECO: CJNE A, #0AAH, S_FL
S_NXT: SETB 7FH
SND_S: MOV B, #53
MOV R1,#31H
MOV SBUF,30H
SND_USR:MOV A, @R1
INC R1
JNB TI, $
CLR TI
MOV SBUF, A
DJNZ B, SND_USR
CPL 7FH
JNB 7FH, SND_S
JMP S_SCS
S_FL: JMP S_FAIL
S_SCS:
CALL BLACK
SETB 0F0H
MOV 18H,#0B4H
MOV 19H,#20
MOV STR_START,#26H
MOV STR_LEN,#8
MOV DPTR, #STR_SND
8/8/2019 Digital Name Card - micro processor project
23/38
2
CALL FECH_STR
MOV 18H,#0B8H
MOV 19H,#20
MOV STR_START,#26H
MOV STR_LEN,#8
MOV DPTR, #STR_SC
CALL FECH_STR
JB ENTER, $
CLR RI
CLR TI
JMP MAIN_MENU
S_FAIL:
CALL BLACK
SETB 0F0H
MOV 18H,#0B4H
MOV 19H,#20
MOV STR_START,#26H
MOV STR_LEN,#8
MOV DPTR, #STR_SND
CALL FECH_STR
MOV 18H,#0B8H
MOV 19H,#16
MOV STR_START,#26H
MOV STR_LEN,#8
MOV DPTR, #STR_FL
CALL FECH_STR
JB ENTER, $
CLR RI
CLR TI
JMP MAIN_MENU
FECH_STR:
MOV R1, #26H
MOV R0, #0FECH_LP:MOV A, R0
MOVC A, @A+DPTR
MOV @R1, A
INC R1
INC R0
CJNE R0,#08H, FECH_LP
CALL WRT_IN_ONE_PAGE
RET
STR_SND:
DB 'SENDING '
STR_SC:
DB ' DONE 'STR_FL:
DB ' FAILED '
DELAY:
SetB PSW.3
MOV R0,#20
L1: MOV R1,#100
L2: DJNZ R1,L2
DJNZ R0,L1
CLR PSW.3
RET
LONG_DELAY :
SetB PSW.3
MOV R0,#255
L_1: MOV R1,#255
L_2: DJNZ R1,L_2
DJNZ R0,L_1
CLR PSW.3
RET
INS:
CLR P0.2
CALL CLK_DATA
RET
DTA:
SETB P0.2
CALL CLK_DATA
RET
DTA_DELAY:
SETB P0.2
CALL CLK_DATA
CALL DELAY
RET
;p0.0 READ
;p0.1 WRITE
;p0.2 register select: 1 for data,0 for instruction
;p3.7 reset 1 for normal running, 0 for initialization
;p3.5 Chip Select
CLK_DATA:
SETB P0.0
CLR P0.1
CLR LCD_ACCESS
NOP;CALL DIULEI
MOV P2, A
NOP
SETB LCD_ACCESS
NOP
SETB P0.1
RET
DEFINE_USR:
MOV B, #54
MOV R1, #30H
MOV DPTR, #USR_DEFINED1
MOV A, #0MOV R2,#0
SV_USR:
MOVC A, @A+DPTR
MOV @R1, A
INC R1
INC R2
MOV A,R2
DJNZ B, SV_USR
8/8/2019 Digital Name Card - micro processor project
24/38
2
RET
;----------------------INFRARED INTO FRAM-----------------------
INFRARED_INTO_FRAM:
call black
CALL INFRARED_CONFIRM
MOV R0,18H
CJNE R0,#0B7H,INFRARED_INTO_FRAM_RET
MOV DPTR,#0
CALL MEMORY_READ
MOV R0,A
INC A
CALL MEMORY_WRITE; INCREMENT THE NUMBER OF USERS
call memory_read
INC DPTR
INFRARED_INTO_FRAM_LOOP:
MOV R1,#54
INFRARED_INTO_FRAM_LOOP1:
INC DPTR
DJNZ R1,INFRARED_INTO_FRAM_LOOP1
DJNZ R0,INFRARED_INTO_FRAM_LOOP
CALL USER_INTO_FRAM
INFRARED_INTO_FRAM_RET:
POP ACC
POP ACC
MOV DPTR, #MAIN_MENU
PUSH DPL
PUSH DPH
RETI
;----------------------------------------------------------------
;----------------------external memory access----------------------------------
LD_USR:
CLR LCD_ACCESS
CALL BLACKSETB LCD_ACCESS
MOV R0,#1
MOV R2,#0
CALL MEMORY_READ
MOV 1EH, #30H
PUSH 11H
SETB PSW.3
MOV B,#30H
;CALL MEMORY_SET
SV_STK: MOV R1,#30H
MOV R0,#1
MOV R2,#0MOV R3,#54
SV_STK_LOOP:
CALL MEMORY_READ
MOV@ R1,A
INC R1
INC R0
DJNZ R3,SV_STK_LOOP
call nmcard
;-----------MEMORY TEST-----------------
MEMORY_TEST:
CLR EA
CALL MEMORY_SET
MOV DPTR,#0
MOV A,#3
CALL MEMORY_WRITE
MOV DPTR,#USR_DEFINED
CALL USR_INTO_RAM
MOV DPTR,#1
CALL USER_INTO_FRAM
MOV DPTR,#USR_DEFINED1
CALL USR_INTO_RAM
MOV DPTR,#55
CALL USER_INTO_FRAM
MOV DPTR,#USR_DEFINED2
CALL USR_INTO_RAM
MOV DPTR,#109
CALL USER_INTO_FRAM
;JMP LD_USR
RET
USR_INTO_RAM:
MOV R1,#30H
MOV R2,#0
MOV R3,#54
INPUT_USER:
MOV A,R2
MOVC A,@A+DPTR
MOV @R1,A
INC R2
INC R1
DJNZ R3,INPUT_USERRET
USER_INTO_FRAM:
MOV R1,#30H
MOV R3,#54
INPUT_FRAM:
MOV A,@R1
CALL MEMORY_WRITE
INC DPTR
INC R1
DJNZ R3,INPUT_FRAM
;MOV R3,#54
;MOV DPTR,#109;MOV R1,#30H
;TEST_LOOP_MEMO:
;CALL MEMORY_READ
;MOV @R1,A
;INC DPTR
;INC R1
;DJNZ R3,TEST_LOOP_MEMO
RET
8/8/2019 Digital Name Card - micro processor project
25/38
2
;-------------------------------------------------
CE EQU P3.4
OE EQU P3.3;RD
WE EQU P3.2;WRITE
MEMORY_SET:
CLR CE
NOP
SETB CE
NOP
SETB WE
SETB OE
MOV P2,#0FFH
MOV P0,#0FFH
MOV P1,#0FFH
RET
MEMORY_READ:
MOV P1,#0FFH
SETB WE
MOV P0,DPL;dpl IS A0 TO A7
MOV P2,DPH;DPH IS A8 TO A14
CLR CE
CLR OE
MOV A,P1
NOP
SETB CE
SETB OE
NOP
RET
MEMORY_WRITE:
MOV P0,DPL;DPL IS A0 TO A7
MOV P2,DPH;DPH IS A8 TO A14
CLR WE
CLR CEMOV P1,A
NOP
nop
SETB CE
SETB WE
NOP
RET
;----------------------external memory access----------------------------------
NMCARD:
SETB LCD_ACCESS
; WRITE name
MOV STR_LEN, 30HMOV STR_START, #31H
CLR F0
MOV 18H, #0B1H
MOV 19H, #005H
CALL WRT_IN_ONE_PAGE
; WRITE EMAIL
MOV STR_LEN, 42H
MOV STR_START, #43H
MOV 18H, #0B5H
MOV 19H, #005H
CALL WRT_IN_ONE_PAGE
;CNVRT PHONE
MOV B, R1
PUSH 0F0H
MOV B, R0
PUSH 0F0H
CLR 7FH
MOV R1,#3CH
MOV R0,#30H
MOV B, #6
MVUPPR:
MOV A, @R1
SWAP A
ANL A, #0FH
ADD A,#30H
MOV @R0, A
INC R0
MOV A,#0
XCHD A, @R1
ADD A,#30H
MOV @R0, A
INC R0
INC R1
DJNZ B, MVUPPR
;JB 7FH, CNVERT
;MOV R1,# 41H
;MOV R0,# 41H
;MOV B, #4
;SETB 7FH
;SJMP MVUPPR
CNVERT: POP 0F0H
MOV R0, B
POP 0F0H
MOV R1, B
CLR PSW.5
MOV STR_LEN, #12
MOV STR_START, #30H
MOV 18H, #0B9HMOV 19H, #005H
CALL WRT_IN_ONE_PAGE
; DRAW LOGO
SETB PSW.4
MOV 20h, #00
MOV R5, #0B8H
MOV R4, #016H
MOV R3, #005H
8/8/2019 Digital Name Card - micro processor project
26/38
2
MOV R0, #54H
MOV R7, #3
LGO1: MOV A,R5
CALL INS
MOV A, R4
CALL INS
MOV A, R3
CALL INS
MOV R6,#06
LGO2: CLR 7FH
MOV A, @R0
INC R0
SWAP A
SD_LGO2:
MOV C, ACC.0
MOV 07H, C
MOV C,ACC.1
MOV 05H, C
MOV C,ACC.2
MOV 03H, C
MOV C,ACC.3
MOV 01H, C
MOV B, A
MOV A, 20H
RR A
ORL A, 20H
CPL A
CALL DTA
CALL DTA
JB 7FH, EX_LGO2
SETB 7FH
MOV A, B
SWAP AMOV B, A
JMP SD_LGO2
EX_LGO2: DJNZ R6, LGO2
INC R5
DJNZ R7, LGO1
CLR PSW.4
SETB ENTER
NMCARD_RETURN:
JB ENTER, NMCARD_RETURN
RET
USR_DEFINED:
DB 8DB 'L. Leene'
DB 00, 00, 00, 08H , 52H, 65H, 15H, 23H, 68H;18
DB 13
DB '[email protected]'
DB 00, 00, 00, 00;18
DB 000H, 001H, 010H, 001H, 010H, 000H
DB 000H, 00FH, 0f0H, 00fH, 0F0H, 000H
DB 0C6H, 023H, 011H, 011H, 032H, 06CH
USR_DEFINED1:
DB 8
DB 'TIM '
DB 00, 00, 00, 08H , 52H, 68H, 50H, 78H, 48H;18
DB 15
DB '[email protected] '
DB 00, 00;18
DB 000H, 001H, 010H, 001H, 010H, 000H
DB 000H, 00FH, 0f0H, 00fH, 0F0H, 000H
DB 0C6H, 023H, 011H, 011H, 032H, 06CH
USR_DEFINED2:
DB 10
DB 'JUFENG YIN'
DB 00, 08H , 52H, 66H, 22H, 36H, 96H;18
DB 13
DB '[email protected]'
DB 00, 00, 00, 00;18
DB 000H, 007H, 044H, 044H, 046H, 067H
DB 0f8H, 08fH, 099H, 099H, 0f1H, 01fH
DB 0e6H, 062H, 022H, 022H, 02eH, 000H
;------------------------------------------------------
;R0 - FRM ABS
;R1 - Y ABS & Y POSITION
;R2 - X ABS
;R3 - FRM MAX
;R4 - CURRENT FRM NUMBER
;R5 - ARRAY GEN VAR
;R6 - X LOOP VAR
;R7 - Y LOOP VAR
A_INIT:
SETB PSW.4 ; REG BANK 1
MOV R4, #03EH ; RESET FRAME
MOV R3, #03FH ; SET FRAME NUMBERMOV DPTR,#PTABLE ; MOVE POINTER
A_LOOP:
MOV A, R4
ANL A, #03FH
MOVC A,@A+DPTR
MOV R0,A
MOV A,#010110000b
CALL INS
MOV A,#000010000b
CALL INS
MOV A,#000000000b
CALL INS ;SET CURSOR PAGE & COLLMOV R6,#0 ;IMG size 132 pix.x
A_LOOP1:
CLR C
MOV A, R6
RL A
RL A
RL A
MOV R1, A
8/8/2019 Digital Name Card - micro processor project
27/38
2
MOV A,#010110000b
ADD A,R6
CLR PSW.4
CALL INS
MOV A,#000010000b
CALL INS
MOV A,#000000000b
CALL INS
SETB PSW.4
MOV R7,#128 ;IMG size 132 pix.y
A_LOOP2:
MOV A, R7
RR A
ANL A, #03FH
MOVC A,@A+DPTR
MOV R2, A
MOV R5, #08
MOV 1FH, #00
MOV 1EH, #00
ARRAY_GEN:
MOV A, R1
ANL A, #03FH
MOVC A,@A+DPTR
ADD A,R0
ADD A,R2
ADD A,#40
RLC Acpl c
MOV 00H,C
ADD A,#20
RLC A
cpl c
MOV 08H,C
MOV A, 21H
RR A
MOV 21H,A
MOV A, 20H
RR A
MOV 20H,AINC R1
DJNZ R5,ARRAY_GEN
MOV A, R1
ADD A, -8
MOV R1, A
CLR PSW.4
MOV A, 20H
CALL DTA
MOV A, 21H
CALL DTA
SETB PSW.4
DJNZ R7,A_LOOP2
INC R6
MOV A,R6
ADD A, -7
JNZ A_LOOP1
MOV R5, #05
WRITE_STRING:
MOV A, R5
MOV B, #0CH
MUL AB
ADD A, R4
RL A
ADD A,#80H
JB CY, OF
ADD A,#80H
OF: MOV 19H,A
MOV 18H,#0B8H
MOV A, R5
DEC A
MOV DPTR,#USR
MOVC A,@A+DPTR
MOV 1AH,A
CLR PSW.4
CALL WRITE_TRACY
SETB PSW.4
MOV DPTR,#PTABLE
DJNZ R5,WRITE_STRING
JNB ENTER,NT3_NEXT;
DJNZ R4,NT3JMP A_INIT
NT3:
LJMP A_LOOP
NT3_NEXT:
CLR PSW.4
JMP MAIN_MENU
USR:
DB 17, 26, 02, 03, 38
PTABLE:
DB 020H,023H,026H,029H,02CH,02FH,032H,035H,037H,039H
DB 03BH,03CH,03EH,03FH,040H,040H,040H,040H,03FH,03EH
DB 03DH,03CH,03AH,038H,036H,033H,031H,02EH,02BH,028HDB 025H,022H,01EH,01BH,018H,015H,012H,00FH,00DH,00AH
DB 008H,006H,004H,003H,002H,001H,000H,000H,000H,000H
DB 001H,002H,004H,005H,007H,009H,00BH,00EH,011H,014H
DB 017H,01AH,01DH,020H
;-----------------WRT WORDS-----------MAXIMUM 5 LETTERS---
;22H 23H 24H IS BEING USED IN THIS FUNCTION
WRITE_TRACY:
;_______________________________ SS MOVING NAME
8/8/2019 Digital Name Card - micro processor project
28/38
2
MOV R1,18H
SETB PSW.3
MOV A,19H
ANL A, #0F0H
SWAP A
ORL A, #010H
MOV R6, A
MOV A,19H
ANL A,#0FH
MOV R3, A
CLR PSW.3
MOV DPTR,#LETTER_TABLE
CALL WRT_PER_LETTER
RET
; ;------------WRITE FIVE LETTERS
WRT_PER_LETTER:
MOV R3,#4
MOV R4,#0;to record which column it is accessing
;ADJUST THE DPTR TO THE WANTED LETTERS
MOV A, OFFSET ;
8/8/2019 Digital Name Card - micro processor project
29/38
2
MOV STR_LEN,#5
MOV STR_START,#26H
MOV 26H,#'Y'
MOV 27H,#'O'
MOV 28H,#'U'
MOV 29H,#'R'
MOV 2AH,#' '
CALL WRT_IN_ONE_PAGE
MOV 18H,#0B7H
MOV 19H,#88
MOV STR_LEN,#4
MOV STR_START,#26H
MOV 26H,#'D'
MOV 27H,#'A'
MOV 28H,#'T'
MOV 29H,#'A'
CALL WRT_IN_ONE_PAGE
MOV A,#0FFH
SETUP1:
DJNZ ACC, SETUP1
RET
;------------------------------------------
CONFIRM_SEND_PERSON:
MOV 18H,#0B3H
MOV 19H,#20
CLR F0
MOV STR_START,#26H
MOV STR_LEN,#8
MOV 26H,#'C'
MOV 27H,#'O'
MOV 28H,#'N'
MOV 29H,#'F'
MOV 2AH,#'I'MOV 2BH,#'R'
MOV 2CH,#'M'
MOV 2DH,#'?'
CALL WRT_IN_ONE_PAGE
MOV 18H,#0B6H
MOV 19H,#20
MOV STR_START,#26H
MOV STR_LEN,#3
MOV 26H,#'Y'
MOV 27H,#'E'
MOV 28H,#'S'
CALL WRT_IN_ONE_PAGEMOV 18H,#0B8H
MOV 19H,#20
MOV STR_START,#26H
MOV STR_LEN,#2
MOV 26H,#'N'
MOV 27H,#'O'
CALL WRT_IN_ONE_PAGE
MOV 18H,#0B6H
CALL WRITE_ARROW
MOV P0,#0FFH
INFRARED_CONFIRM_CHECK:
JNB UP, INFRARED_CONFIRM_CHECKUP
JNB DOWN, INFRARED_CONFIRM_CHECKDOWN
JNB ENTER, INFRARED_CONFIRM_CHECKRETURN
SJMP INFRARED_CONFIRM_CHECK
INFRARED_CONFIRM_CHECKUP:
CALL ERASE_ARROW
MOV R0,18H
CJNE R0,#0B6H,INFRARED_CONFIRM_CHECKUP0
MOV 18H,#0B8H
CALL WRITE_ARROW
SJMP INFRARED_CONFIRM_CHECKUP_END
INFRARED_CONFIRM_CHECKUP0:
MOV 18H,#0B6H
CALL WRITE_ARROW
INFRARED_CONFIRM_CHECKUP_END:
JNB UP,INFRARED_CONFIRM_CHECKUP_END
LJMP INFRARED_CONFIRM_CHECK
INFRARED_CONFIRM_CHECKDOWN :
CALL ERASE_ARROW
MOV R0,18H
CJNE R0,#0B6H,INFRARED_CONFIRM_CHECKDOWN0
MOV 18H,#0B8H
CALL WRITE_ARROW
SJMP INFRARED_CONFIRM_CHECKDOWN_END
INFRARED_CONFIRM_CHECKDOWN0:
MOV 18H,#0B6H
CALL WRITE_ARROW
INFRARED_CONFIRM_CHECKDOWN_END:
JNB DOWN,INFRARED_CONFIRM_CHECKDOWN_END
LJMP INFRARED_CONFIRM_CHECKINFRARED_CONFIRM_CHECKRETURN :
MOV 10H,#4
INFRARED_CONFIRM_CHECKRETURN_LOOP:
CALL ERASE_ARROW
CALL LONG_DELAY
CALL LONG_DELAY
CALL WRITE_ARROW
CALL LONG_DELAY
CALL LONG_DELAY
DJNZ 10H, INFRARED_CONFIRM_CHECKRETURN_LOOP
MOV R0,18H
CJNE R0,#0B6H,DIULEILOUMOURET
DIULEILOUMOU:
LJMP MAIN_MENU
;------------------CONTACT BOOK--------------
CONTACT_BOOK:
CONTACT_BOOK_INDEX EQU 20H
CONTACT_BOOK_NUM EQU 1FH
MOV DPTR,#0
8/8/2019 Digital Name Card - micro processor project
30/38
3
CALL MEMORY_READ
INC DPTR
MOV 18H,#0B0H
MOV 21H,A
MOV 1FH,A
CONTACT_BOOK_DISPLAY:; THIS WILL DISPLAY A LIST OF NAMES
CALL MEMORY_READ
MOV 25H,A
MOV 30H,25H
INC DPTR
CALL CONTACT_BOOK_NAME;25H IS THE LENGTH OF THE NAME
STRING
INC 18H
INC 18H
DJNZ 21H,CONTACT_BOOK_DISPLAY
MOV 18H,#0B0H
CALL WRITE_ARROW
MOV P0,#0FFH
CONTACT_BOOK_LOOP:
JNB UP, CONTACT_BOOK_UP
JNB DOWN,CONTACT_BOOK_DOWN
JNB ENTER,CONTACT_BOOK_ENTER
SJMP CONTACT_BOOK_LOOP
CONTACT_BOOK_RET:
MOV R0,18H
MOV CONTACT_BOOK_INDEX,#0
CONTACT_BOOK_HERE:
CJNE R0,#0B0H,CONTACT_BOOK_END
LJMP CONTACT_BOOK_PERSON
CONTACT_BOOK_END:
DEC R0
DEC R0
INC CONTACT_BOOK_INDEXSJMP CONTACT_BOOK_HERE
;CONTACT BOOK INDEX IS 0 TO 5
; AFTER SET THE INDEX, DISPLAY A PERSON'S INFO
CONTACT_BOOK_UP:
CALL ERASE_ARROW
MOV R0,18H
CJNE R0,#0B0H,CONTACT_BOOK_UP_NORMAL
CALL CONTACT_BOOK_BOTTOM
MOV 18H,R2
CALL WRITE_ARROW
SJMP CONTACT_BOOK_UP_RET
CONTACT_BOOK_UP_NORMAL:DEC 18H
DEC 18H
CALL WRITE_ARROW
CONTACT_BOOK_UP_RET:
JNB UP,$
SJMP CONTACT_BOOK_LOOP
CONTACT_BOOK_DOWN:
CALL ERASE_ARROW
MOV A,18H
CALL CONTACT_BOOK_BOTTOM
;NOW R2 IS THE BOTTOM PAGE ADDRESS
CJNE A,02H,CONTACT_BOOK_DOWN_NORMAL
MOV 18H,#0B0H
CALL WRITE_ARROW
SJMP CONTACT_BOOK_DOWN_RET
CONTACT_BOOK_DOWN_NORMAL:
INC 18H
INC 18H
CALL WRITE_ARROW
CONTACT_BOOK_DOWN_RET:
JNB DOWN,$
JMP CONTACT_BOOK_LOOP
CONTACT_BOOK_ENTER:
MOV 10H,#4
CONTACT_BOOK_ENTER_LOOP:
CALL ERASE_ARROW
CALL LONG_DELAY
CALL LONG_DELAY
CALL WRITE_ARROW
CALL LONG_DELAY
CALL LONG_DELAY
DJNZ 10H, CONTACT_BOOK_ENTER_LOOP
JMP CONTACT_BOOK_RET
CONTACT_BOOK_NAME:; TO MOVE THE NAME FROM EXTERNAL
MEMORY TO RAM
MOV R1,#31H
CONTACT_BOOK_NAME_LOOP:
CALL MEMORY_READ
MOV @R1,A
INC R1
INC DPTRDJNZ 25H,CONTACT_BOOK_NAME_LOOP
MOV 25H,30H
SETB C
MOV A,#54
SUBB A,25H
MOV R0,A
CONTACT_BOOK_NAME_LOOP1:
INC DPTR
DJNZ R0,CONTACT_BOOK_NAME_LOOP1
MOV 7FH,DPH
MOV 7EH,DPL
MOV 19H,#30CLR F0
MOV STR_START,#31H
MOV STR_LEN,30H
CALL WRT_IN_ONE_PAGE
MOV DPH,7FH
MOV DPL,7EH
RET
8/8/2019 Digital Name Card - micro processor project
31/38
3
CONTACT_BOOK_BOTTOM:;RETURN R2 AS THE BOTTOM PAGE
ADDRESS
MOV R1,CONTACT_BOOK_NUM
DEC R1;
MOV R2,#0B0H
CONTACT_BOOK_UP_GAN:
INC R2
INC R2
DJNZ R1,CONTACT_BOOK_UP_GAN; A SPECIAL CASE
RET
CONTACT_BOOK_PERSON:
MOV R1,CONTACT_BOOK_INDEX
MOV DPTR,#1
CJNE R1,#0,CONTACT_BOOK_PERSON_CONT
SJMP CONTACT_BOOK_PERSON_READ
CONTACT_BOOK_PERSON_CONT:
MOV R5,#54
CONTACT_BOOK_PERSON_CONT_LOOP:
INC DPTR
DJNZ R5,CONTACT_BOOK_PERSON_CONT_LOOP
DJNZ R1,CONTACT_BOOK_PERSON_CONT
CONTACT_BOOK_PERSON_READ:
MOV R3,#54
MOV R1,#30H
CONTACT_BOOK_PERSON_DISPLAY:
CALL MEMORY_READ
MOV @R1,A
INC DPTR
INC R1
DJNZ R3,CONTACT_BOOK_PERSON_DISPLAY
CALL BLACK
JB 6FH,CONTACT_BOOK_NORMAL_DISPLAY
LJMP CONFIRM_SEND_PERSONCONTACT_BOOK_NORMAL_DISPLAY:
LJMP NMCARD
;---------------------WRT IN TWO PAGE---
WRT_IN_ONE_PAGE:
MOV 0CH,18H ;0CH IS THE PAGE ADDRESS
;0AH AND 0BH STORE THE COLUMN ADDRESS
;;--------------CURSOR IS SET.
;-----TEST LOOP-----
WRT_IN_ONE_PAGE_LOOP:
CALL TRANSLATE_COLUMN_POINTER
MOV R0,STR_START
MOV A,@R0CALL MATCH_OFFSET
CALL WRT_IN_ONE_PAGE_ONE_LETTER
MOV A,19H
ADD A,#6
JNB F0, WRT_SMALL
ADD A,#6
WRT_SMALL:
MOV 19H,A
INC STR_START
CALL LONG_DELAY
DJNZ STR_LEN,WRT_IN_ONE_PAGE_LOOP
RET; RETURN OF WRT IN ONE PAGE
WRT_IN_ONE_PAGE_ONE_LETTER:
MOV DPTR,#LETTER_TABLE
MOV A,OFFSET
MOV B,#8
MUL AB
ADD A,DPL
MOV DPL,A
MOV A,B
ADDC A,DPH
MOV DPH,A
;NOW DPTR IS AT THE LETTER WE WANNA INPUT
MOV R3,#2
MOV R2,#0
WRT_IN_ONE_PAGE_HALF_LETTER:
MOV A,0CH
CALL INS
MOV A,0AH
CALL INS
MOV A,0BH
CALL INS
MOV R0,#4
MOV R1,#25H
WRT_IN_ONE_PAGE_READ_ONE_LETTER:
MOV A,R2
MOVC A,@A+DPTR
MOV @R1,A
DEC R1
INC R2
DJNZ R0,WRT_IN_ONE_PAGE_READ_ONE_LETTERMOV R0,#6
WRT_IN_ONE_PAGE_DISPLAY:
MOV C,15H
MOV B.7,C
MOV A,22H
RLC A
MOV 22H,A
MOV C,1DH
MOV B.6,C
MOV A,23H
RLC A
MOV 23H,AMOV C,25H
MOV B.5,C
MOV A,24H
RLC A
MOV 24H,A
MOV C,2DH
MOV B.4,C
MOV A,25H
8/8/2019 Digital Name Card - micro processor project
32/38
3
RLC A
MOV 25H,A
MOV C,B.7
MOV ACC.7,C
MOV ACC.6,C
MOV C,B.6
MOV ACC.5,C
MOV ACC.4,C
MOV C,B.5
MOV ACC.3,C
MOV ACC.2,C
MOV C,B.4
MOV ACC.1,C
MOV ACC.0,C
CPL A
CALL DTA
CALL DTA
JNB F0,WRT_IN_ONE_PAGE_DISPLAY_SMALL
CALL DTA
CALL DTA
WRT_IN_ONE_PAGE_DISPLAY_SMALL:
DJNZ R0, WRT_IN_ONE_PAGE_DISPLAY
INC 0CH
DJNZ R3, WRT_IN_ONE_PAGE_HALF_LETTER
;RESET POINTERS
MOV DPTR,#LETTER_TABLE
DEC 0CH
DEC 0CH
RET;RETURN OF WRT ONE LETTER IN ONE PAGE
;-------------------------------------
START_MENU:
CALL BLACK
MOV 18H,#0B1HMOV 19H,#40
SETB F0
MOV STR_START,#26H
MOV STR_LEN,#4
MOV 26H,#'M'
MOV 27H,#'E'
MOV 28H,#'N'
MOV 29H,#'U'
CALL WRT_IN_ONE_PAGE
MOV 18H,#0B4H
MOV 19H,#20
CLR F0MOV STR_START,#26H
MOV STR_LEN,#8
MOV 26H,#'D'
MOV 27H,#'I'
MOV 28H,#'S'
MOV 29H,#'P'
MOV 2AH,#'L'
MOV 2BH,#'A'
MOV 2CH,#'Y'
MOV 2DH,#' '
CALL WRT_IN_ONE_PAGE
MOV 18H,#0B4H
MOV 19H,#68
MOV STR_START,#26H
MOV STR_LEN,#4
MOV 26H,#'I'
MOV 27H,#'N'
MOV 28H,#'F'
MOV 29H,#'O'
CALL WRT_IN_ONE_PAGE
MOV 18H,#0B6H
MOV 19H,#20
MOV STR_START,#26H
MOV STR_LEN,#8
MOV 26H,#'I'
MOV 27H,#'N'
MOV 28H,#'F'
MOV 29H,#'R'
MOV 2AH,#'A'
MOV 2BH,#'R'
MOV 2CH,#'E'
MOV 2DH,#'D'
CALL WRT_IN_ONE_PAGE
MOV 18H,#0B8H
MOV 19H,#20
MOV STR_START,#26H
MOV STR_LEN,#8
MOV 26H,#'S'
MOV 27H,#'C'
MOV 28H,#'R'
MOV 29H,#'E'MOV 2AH,#'E'
MOV 2BH,#'N'
MOV 2CH,#' '
MOV 2DH,#'S'
CALL WRT_IN_ONE_PAGE
MOV 18H,#0B8H
MOV 19H,#68
MOV STR_START,#26H
MOV STR_LEN,#4
MOV 26H,#'A'
MOV 27H,#'V'
MOV 28H,#'E'MOV 29H,#'R'
CALL WRT_IN_ONE_PAGE
MOV 18H,#0BAH
MOV 19H,#20
MOV STR_START,#26H
MOV STR_LEN,#8
MOV 26H,#'C'
MOV 27H,#'O'
8/8/2019 Digital Name Card - micro processor project
33/38
3
MOV 28H,#'N'
MOV 29H,#'T'
MOV 2AH,#'A'
MOV 2BH,#'C'
MOV 2CH,#' T'
MOV 2DH,#' '
CALL WRT_IN_ONE_PAGE
MOV 18H,#0BAH
MOV 19H,#68
MOV STR_START,#26H
MOV STR_LEN,#4
MOV 26H,#'B'
MOV 27H,#'O'
MOV 28H,#'O'
MOV 29H,#'K'
CALL WRT_IN_ONE_PAGE
MOV 18H,#0B4H
CALL WRITE_ARROW
UP EQU P0.5
DOWN EQU P0.6
ENTER EQU P0.7
SETB UP
SETB DOWN
SETB ENTER
START_MENU_LOOP:
JNB UP,START_MENU_UP
; CALL LONG_DELAY
JNB DOWN,START_MENU_DOWN
;CALL LONG_DELAY
JNB ENTER,START_MENU_RETURN
;CALL LONG_DELAY
SJMP START_MENU_LOOPSTART_MENU_UP:
CALL ERASE_ARROW
MOV R0,18H
CJNE R0,#0B4H,START_MENU_UP0
MOV 18H,#0BAH
CALL WRITE_ARROW
SJMP START_MENU_UP_END
START_MENU_UP0:
CJNE R0,#0B6H,START_MENU_UP1
MOV 18H,#0B4H
CALL WRITE_ARROW
SJMP START_MENU_UP_ENDSTART_MENU_UP1:
CJNE R0,#0B8H,START_MENU_UP2
MOV 18H,#0B6H
CALL WRITE_ARROW
SJMP START_MENU_UP_END
START_MENU_UP2:
MOV 18H,#0B8H
CALL WRITE_ARROW
START_MENU_UP_END:
JNB UP,START_MENU_UP_END
LJMP START_MENU_LOOP
START_MENU_DOWN :
CALL ERASE_ARROW
MOV R0,18H
CJNE R0,#0B4H,START_MENU_DOWN0
MOV 18H,#0B6H
CALL WRITE_ARROW
SJMP START_MENU_DOWN_END
START_MENU_DOWN0:
CJNE R0,#0B6H,START_MENU_DOWN1
MOV 18H,#0B8H
CALL WRITE_ARROW
SJMP START_MENU_DOWN_END
START_MENU_DOWN1:
CJNE R0,#0B8H,START_MENU_DOWN2
MOV 18H,#0BAH
CALL WRITE_ARROW
SJMP START_MENU_DOWN_END
START_MENU_DOWN2:
MOV 18H,#0B4H
CALL WRITE_ARROW
START_MENU_DOWN_END:
JNB DOWN,START_MENU_DOWN_END
LJMP START_MENU_LOOP
START_MENU_RETURN :
MOV 10H,#5
START_MENU_RETURN_LOOP:
CALL ERASE_ARROW
CALL LONG_DELAY
CALL LONG_DELAY
CALL WRITE_ARROWCALL LONG_DELAY
CALL LONG_DELAY
DJNZ 10H, START_MENU_RETURN_LOOP
RET
;WHEN IT RETURN,
WRITE_ARROW:
MOV 19H,#01
SETB F0
MOV STR_START,#26H
MOV STR_LEN,#1
MOV 26H,#3EH
CALL WRT_IN_ONE_PAGERET
ERASE_ARROW:
MOV 19H,#01
SETB F0
MOV STR_START,#26H
MOV STR_LEN,#1
MOV 26H,#20H
CALL WRT_IN_ONE_PAGE
8/8/2019 Digital Name Card - micro processor project
34/38
8/8/2019 Digital Name Card - micro processor project
35/38
3
CJNE A,#3FH,MATCH_UNDERSCORE
MOV OFFSET,#42
RET
MATCH_UNDERSCORE:
CJNE A,#5FH,MATCH_ARROW
MOV OFFSET,#41
RET
MATCH_ARROW:
CJNE A,#3EH,MATCH_BLANK
MOV OFFSET,#40
RET
MATCH_BLANK:;BLANK
CJNE A,#20H,MATCH_DOT
MOV OFFSET,#38;BLANK
RET
MATCH_DOT:;DOT
CJNE A,#2EH,MATCH_NUMBERS
MOV OFFSET,#37
RET
MATCH_NUMBERS:;NUMBERS AND ':'
CJNE A,#3AH,MATCH_NUMBERS_NEXT
MOV OFFSET,#39;':'
RET
MATCH_NUMBERS_NEXT:
JNB CY,MATCH_LETTERS
CLR C
SUBB A,#48
MOV OFFSET,A
RET
MATCH_LETTERS:;LETTERS AND '@'
CJNE A,#5AH,MATCH_LETTERS_NEXT
MOV OFFSET,#36
RETMATCH_LETTERS_NEXT:
JNB CY,MATCH_LETTER_LOWER_CASE
CLR C
SUBB A,#54
MOV OFFSET,A
RET
MATCH_LETTER_LOWER_CASE:
CLR C
SUBB A,#86
MOV OFFSET,A
RET;RET OF MATCH_OFFSET
;----------------------------------------------------------------------------------------LETTER_TABLE:
DB 011100B ;0
DB 100010B ;0
DB 100110B; 0
DB 101010B ;0
DB 110010B ;0
DB 100010B ;0
DB 011100B ;0
DB 000000B ;0
DB 001000B ;1
DB 011000B
DB 001000B
DB 001000B
DB 001000B
DB 001000B
DB 011100B
DB 000000B
DB 011100B ;2
DB 100010B
DB 000010B
DB 000100B
DB 001000B
DB 010000B
DB 111110B
DB 000000B
DB 111110B ;3
DB 000100B
DB 001000B
DB 000100B
DB 000010B
DB 100010B
DB 011100B
DB 000000B
DB 000100B ;4
DB 001100B
DB 010100B
DB 100100B
DB 111110B
DB 000100B
DB 000100B
DB 000000BDB 111110B ;5
DB 100000B
DB 111100B
DB 000010B
DB 000010B
DB 100010B
DB 011100B
DB 000000B
DB 001100B ;6
DB 010000B
DB 100000B
DB 111100BDB 100010B
DB 100010B
DB 011100B
DB 000000B
DB 111110B ;7
DB 000010B
DB 000100B
DB 001000B
8/8/2019 Digital Name Card - micro processor project
36/38
3
DB 010000B
DB 010000B
DB 010000B
DB 000000B
DB 011100B ;8
DB 100010B
DB 100010B
DB 011100B
DB 100010B
DB 100010B
DB 011100B
DB 000000B
DB 11100B ;9
DB 100010B
DB 100010B
DB 011110B
DB 000010B
DB 000100B
DB 011000B
DB 000000B
DB 011100B ;AT --INDEX 10
DB 100010B
DB 000010B
DB 011010B
DB 101010B
DB 101010B
DB 011100B
DB 000000B
DB 011100B ;A---INDEX 11
DB 100010B
DB 100010B
DB 100010B
DB 111110BDB 100010B
DB 100010B
DB 000000B
DB 111100B ;B
DB 100010B
DB 100010B
DB 111100B
DB 100010B
DB 100010B
DB 111100B
DB 000000B
DB 011100B ;CDB 100010B
DB 100000B
DB 100000B
DB 100000B
DB 100010B
DB 011100B
DB 000000B
DB 111000B ;D
DB 100100B
DB 100010B
DB 100010B
DB 100010B
DB 100100B
DB 111000B
DB 000000B
DB 111110B ;E
DB 100000B
DB 100000B
DB 111100B
DB 100000B
DB 100000B
DB 111110B
DB 000000B
DB 111110B ;F
DB 100000B
DB 100000B
DB 111100B
DB 100000B
DB 100000B
DB 100000B
DB 000000B
DB 011100B ;G
DB 100010B
DB 100000B
DB 101110B
DB 100010B
DB 100010B
DB 011110B
DB 000000B
DB 100010B ;H
DB 100010BDB 100010B
DB 111110B
DB 100010B
DB 100010B
DB 100010B
DB 000000B
DB 011100B ;I
DB 001000B
DB 001000B
DB 001000B
DB 001000B
DB 001000BDB 011100B
DB 000000B
DB 001110B ;J
DB 000100B
DB 000100B
DB 000100B
DB 000100B
DB 100100B
8/8/2019 Digital Name Card - micro processor project
37/38
3
DB 011000B
DB 000000B
DB 100010B ;K
DB 100100B
DB 101000B
DB 110000B
DB 101000B
DB 100100B
DB 100010B
DB 000000B
DB 100000B ;L
DB 100000B
DB 100000B
DB 100000B
DB 100000B
DB 100000B
DB 111110B
DB 000000B
DB 100010B ;M
DB 110110B
DB 101010B
DB 101010B
DB 100010B
DB 100010B
DB 100010B
DB 000000B
DB 100010B ;N
DB 100010B
DB 110010B
DB 101010B
DB 100110B
DB 100010B
DB 100010BDB 000000B
DB 011100B ;O
DB 100010B
DB 100010B
DB 100010B
DB 100010B
DB 100010B
DB 011100B
DB 000000B
DB 111100B ;P
DB 100010B
DB 100010BDB 111100B
DB 100000B
DB 100000B
DB 100000B
DB 000000B
DB 011100B ;Q
DB 100010B
DB 100010B
DB 100010B
DB 101010B
DB 100100B
DB 011010B
DB 000000B
DB 111100B ;R
DB 100010B
DB 100010B
DB 111100B
DB 101000B
DB 100100B
DB 100010B
DB 000000B
DB 011100B ;S
DB 100010B
DB 100000B
DB 011100B
DB 000010B
DB 100010B
DB 011100B
DB 000000B
DB 111110B ;T
DB 001000B
DB 001000B
DB 001000B
DB 001000B
DB 001000B
DB 001000B
DB 000000B
DB 100010B ;U
DB 100010B
DB 100010B
DB 100010BDB 100010B
DB 100010B
DB 011100B
DB 000000B
DB 100010B ;V
DB 100010B
DB 100010B
DB 100010B
DB 100010B
DB 010100B
DB 001000B
DB 000000BDB 100010B ;W
DB 100010B
DB 100010B
DB 101010B
DB 101010B
DB 101010B
DB 010100B
DB 000000B
8/8/2019 Digital Name Card - micro processor project
38/38
DB 100010B ;X
DB 100010B
DB 010100B
DB 001000B
DB 010100B
DB 100010B
DB 100010B
DB 000000B
DB 100010B ;Y
DB 100010B
DB 100010B
DB 010100B
DB 001000B
DB 001000B
DB 001000B
DB 000000B
DB 111110B ;Z --------INDEX 36
DB 000010B
DB 000100B
DB 001000B
DB 010000B
DB 100000B
DB 111110B
DB 000000B
DB 000000B ;A DOT --INDEX 37
DB 000000B
DB 000000B
DB 000000B
DB 000000B
DB 011000B
DB 011000B
DB 000000B
DB 000000B ;BLANK --INDEX 38DB 000000B
DB 000000B
DB 000000B
DB 000000B
DB 000000B
DB 000000B
DB 000000B
DB 000000B; ':' ----------INDEX 39
DB 011000B
DB 011000B
DB 000000B
DB 011000BDB 011000B
DB 000000B
DB 000000B
DB 000000B;ARROW--------INDEX 40
DB 001000B
DB 000100B
DB 111110B
DB 001000B
DB 000000B
DB 000000B
DB 000000B;'_'--------INDEX 41
DB 000000B
DB 000000B
DB 000000B
DB 000000B
DB 000000B
DB 111110B
DB 000000B
DB 011100B;'_'--------INDEX 42
DB 100010B
DB 000010B
DB 000100B
DB 001000B
DB 000000B
DB 001000B
DB 000000B