Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/18/02 17:46
Read: times


 
#18870 - assembly code check
hi,
this is my final code for my project. i have simulate it but when i run it, the result is vary. so, i need some suggestion about it.thanx.
#include <Sfr51.inc> ; SFRs are defined here
RS EQU T1
RW EQU T0
CE EQU INT0

ORG 0
LJMP MAIN

ORG 13H
SETB P2.7 ;turn on LED
MOV DPTR, #MSG1 ;load pointer for message
ACALL TRANS
MOV DPTR, #MSG2 ;load pointer for message
ACALL DATA_DISPLAY

REC:
JB INT1, REC
CLR P2.7 ;turn off LED
MOV DPTR, #MSG3 ;load pointer for message
ACALL TRANS
MOV DPTR, #MSG4 ;load pointer for message
ACALL DATA_DISPLAY
RETI ;return from ISR

ORG 100H

MAIN:
LCALL INIT_LCD
LCALL INIT_SERIAL
MOV IE, #10000100B ;enable external INT1
MOV DPTR, #STANDBY ;load pointer for message
ACALL TRANS

SERIAL_RECV:
ACALL RECV ;wait for data from serial port
MOV DPTR, #MSG4 ;load pointer for message
ACALL DATA_DISPLAY ;display data on lcd
SJMP SERIAL_RECV ;stay in loop indefinitly

INIT_LCD:
MOV A, #30H ;initialize. lcd 1 lines,5*7 matrix
ACALL COMMAND ;issue command
MOV A, #0EH ;lcd on, cursor on
ACALL COMMAND ;issue command
MOV A, #01H ;clear lcd command
ACALL COMMAND ;issue command
MOV A, #06H ;shift cursor right
ACALL COMMAND ;issue command
MOV A, #80H ;cursor: line 1, pos.6
ACALL COMMAND ;issue command
RET ;return to caller

INIT_SERIAL:
MOV TMOD, #20h ;timer 1, mode 2(auto-reload)
MOV TH1, #0FDh ;9600 baud rate
MOV SCON, #50h ;8-bit,1 stop, REN enabled
SETB TR1 ;start timer 1
RET ;return to caller

TRANS:;serial data transfer. ACC has the data
CLR A ;clear the accumulator
MOVC A, @A+DPTR ;get the character
JZ RETURN ;if last character get out
MOV SBUF, A ;load the data
ACALL DATA_DISPLAY

TRANS1:
JNB TI, TRANS1 ;stay here until last bit gone
CLR TI ;get ready for next character
INC DPTR ;next character
SJMP TRANS ;loop to get next character

RETURN:
RET ;return to caller

RECV: ;receive data serially in ACC
JNB RI, RECV ;wait here for character
MOV A, SBUF ;save it in ACC
MOV DPTR, #MSG4
MOVX @DPTR, A
INC DPTR ;next character
JZ RETURN
CLR RI ;get ready for next character
SJMP RECV

COMMAND:
ACALL READY ;is lcd ready
MOV P1, A ;issue command code
CLR RS ;RS=0 for command
CLR RW ;R/W=0 to write to lcd
SETB CE ;E=1 for H to L pulse
CLR CE ;E=0, latch in
RET ;return to caller

DATA_DISPLAY: ;dispaly on LCD
ACALL READY ;is lcd ready?
MOV P1, A ;issue data
SETB RS ;RS=1 for data
CLR RW ;R/W=0 to write to lcd
SETB CE ;E=1 for H to L pulse
CLR CE ;E=0, latch in
RET ;return to caller

READY:
SETB P1.7 ;make p1.7 input port
CLR RS ;RS=0 access command reg
SETB RW ;R/W=1 read command reg

READY1: ;read command reg and check busy flag
CLR CE ;E=1 for H to L pulse
SETB CE ;E=0 H to L pulse
JB P1.7, READY1 ;stay until busy flag=0
RET ;return to caller

;Message that will be display on LCD
STANDBY: DB "STANDBY", 0
MSG1: DB "START RECORD", 0
MSG2: DB "FISNISH PRESS", 0
MSG3: DB "THANK YOU", 0
MSG4: DB (16) , 0

END

List of 18 messages in thread
TopicAuthorDate
assembly code check            01/01/70 00:00      
RE: Use real FULL name            01/01/70 00:00      
RE: assembly code check            01/01/70 00:00      
RE: assembly code check            01/01/70 00:00      
RE: assembly code check            01/01/70 00:00      
RE: assembly code check            01/01/70 00:00      
RE: assembly code check            01/01/70 00:00      
RE: assembly code check            01/01/70 00:00      
RE: assembly code check            01/01/70 00:00      
RE: assembly code check            01/01/70 00:00      
RE: assembly code check            01/01/70 00:00      
RE: assembly code check            01/01/70 00:00      
RE: assembly code check            01/01/70 00:00      
RE: assembly code check            01/01/70 00:00      
RE: assembly code check            01/01/70 00:00      
RE: assembly code check            01/01/70 00:00      
RE: assembly code check            01/01/70 00:00      
RE: assembly code check            01/01/70 00:00      

Back to Subject List