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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/14/02 07:54
Read: times


 
#18610 - help in assembly code?(serial and lcd)
hi,
below is my program. it was a long program because i still new in assembly. i need help so that my program look shorter and run better.
the problem mainly in the interrupt part that i need to display message and also when finish the interrupt rountine, my lcd need to display back what message display when the interrupt occur.
please reply me if i make any mistake in the program.
any suggestion will reply with a thanx in advance.

ORG 0
LJMP MAIN

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

H_2:
CLR A
MOVC A, @A+DPTR ;get the character
JZ REC2 ;if last character get out
ACALL TRANS ;otherwise call transfer
ACALL DATA_DISPLAY ;dispaly on LCD
INC DPTR ;next one
SJMP H_2 ;stay in loop indefinitly

REC2:
MOV DPTR, #MSG2 ;load pointer for message
ACALL H_3

H_3:
CLR A
MOVC A, @A+DPTR ;get the character
JZ REC3 ;if last character get out
ACALL TRANS ;otherwise call transfer
ACALL DATA_DISPLAY ;dispaly on LCD
INC DPTR ;next one
SJMP H_3 ;stay in loop indefinitly

REC3:
JNB INT1, REC3
CLR P2.7
MOV DPTR, #MSG3 ;load pointer for message
ACALL H_4

H_4:
CLR A
MOVC A, @A+DPTR ;get the character
JZ REC4 ;if last character get out
ACALL TRANS ;otherwise call transfer
ACALL DATA_DISPLAY ;dispaly on LCDINC DPTR ;next one
SJMP H_4 ;stay in loop indefinitl

REC4:
RETI

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

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 rigth
ACALL COMMAND ;issue command
MOV A, #86H ;cursor: line 1, pos.6
ACALL COMMAND ;issue command
RET

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

H_1:
CLR A
MOVC A, @A+DPTR ;get the character
JZ B_1 ;if last character get out
ACALL TRANS ;otherwise call transfer
ACALL DATA_DISPLAY ;dispaly on LCD
INC DPTR ;next one
SJMP H_1 ;stay in loop indefinitly

B_1:
ACALL RECV ;wait for data from serial port
ACALL DATA_DISPLAY ;display data on lcd
SJMP B_1 ;stay in loop indefinitly

;serial data transfer. ACC has the data
TRANS:
MOV SBUF, A ;load the data

TRANS1:
JNB TI, TRANS1 ;stay here until last bit gone
CLR TI ;get ready for next character
RET ;return to caller

RECV: ;receive data serially in ACC
JNB RI, RECV ;wait here for character
MOV A, SBUF ;save it in ACC
CLR RI ;get ready for next character
RET ;return to caller

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

DATA_DISPLAY:
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

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

;read command reg and check busy flag
READY1:
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

STANDBY: DB "STANDBY", 0
MSG1: DB "START RECORD", 0
MSG2: DB "FISNISH PRESS BUTTON", 0
MSG3: DB "THANK YOU", 0

END

List of 4 messages in thread
TopicAuthorDate
help in assembly code?(serial and lcd)            01/01/70 00:00      
RE: help in assembly code?(serial and lcd)            01/01/70 00:00      
RE: help in assembly code?(serial and lcd)            01/01/70 00:00      
RE: help in assembly code?(serial and lcd)            01/01/70 00:00      

Back to Subject List