James
10-17-01, 02:05 PM
I am trying to write a serial input routine for the NMIY-031 board that uses the 8051 MCU and the MAX232 serial I/O chip.
I am trying to talk to the chip using MAXTERM at 9600 baud. Using the same 8/N/1 format that is used by the Monitor V1.1 program.
My routine will only catch an occassional character and I can't figure out how to get it to catch each keystroke dependably. Any help would be greatly appreciated.
Here is the code that I am using:
; serial INPUT routine for the 8051 (doesn't work dependably)
; start program
.ORG 8000H
;Monitor send character routine
.EQU PUTC, 0114h
;Set baud Constant for 9600 baud
;Using a 11.0592 MHz crystal
.EQU Baudnum, 0FDh
;set SMOD bit 0 for Baud x 32 rate
ANL PCON,#7Fh
;clear timer T1 configuration only
ANL TMOD,#0h
;set timer T1 as an 8-bit autoload
ORL TMOD,#20h
;set TL to roll over on next cycle
MOV TL1,#0FFh
;TH1 set Baudnum of 0FDh for 9600 baud
MOV TH1,#Baudnum
;set Timer 1 to run
SETB TR1
;set SCON for UART mode 1
MOV SCON,#7Ch
;Prepare to receive
SETB REN
;The following polling loop only catches a
;keyboard character once in a while
;When it does catch a character it
;prints the correct character
;so it seems to be working half-way right
;But why doesn't it catch EVERY character???
;just a loop lable
LOOP: NOP
;Loop here until Char received
GETCHAR: JB RI, RECEIVE
SJMP GETCHAR
;Get the Charcter
RECEIVE: MOV A,SBUF
;Clear the RI bit CLR RI
;Print the Character using a call to the Monitor
LCALL PUTC
;The following code allows me to
;return control to the monitor by typing a period
;This part of the program works just fine. :o)
;copy the character into B
MOV B,A
;Clear the Carry flag
CLR C
;Load A with the period (2Eh)
MOV A,#2Eh
;TEST FOR PERIOD
SUBB A,B
;Return to the Monitor if a period is detected
JZ FINISH
;Otherwise Stay in the program for another input
SJMP LOOP
;back to monitor prompt
FINISH: LJMP 05AH ;
.END
Any help would be appreciated.
If you have a workable character input routine maybe you could just send me the .asm file for that?
Also if anyone has an assembly listing for the Monitor V1.1 program I would also appreciate that.
And finally, I could use an 8051 disassembler
Thanks,
James
I am trying to talk to the chip using MAXTERM at 9600 baud. Using the same 8/N/1 format that is used by the Monitor V1.1 program.
My routine will only catch an occassional character and I can't figure out how to get it to catch each keystroke dependably. Any help would be greatly appreciated.
Here is the code that I am using:
; serial INPUT routine for the 8051 (doesn't work dependably)
; start program
.ORG 8000H
;Monitor send character routine
.EQU PUTC, 0114h
;Set baud Constant for 9600 baud
;Using a 11.0592 MHz crystal
.EQU Baudnum, 0FDh
;set SMOD bit 0 for Baud x 32 rate
ANL PCON,#7Fh
;clear timer T1 configuration only
ANL TMOD,#0h
;set timer T1 as an 8-bit autoload
ORL TMOD,#20h
;set TL to roll over on next cycle
MOV TL1,#0FFh
;TH1 set Baudnum of 0FDh for 9600 baud
MOV TH1,#Baudnum
;set Timer 1 to run
SETB TR1
;set SCON for UART mode 1
MOV SCON,#7Ch
;Prepare to receive
SETB REN
;The following polling loop only catches a
;keyboard character once in a while
;When it does catch a character it
;prints the correct character
;so it seems to be working half-way right
;But why doesn't it catch EVERY character???
;just a loop lable
LOOP: NOP
;Loop here until Char received
GETCHAR: JB RI, RECEIVE
SJMP GETCHAR
;Get the Charcter
RECEIVE: MOV A,SBUF
;Clear the RI bit CLR RI
;Print the Character using a call to the Monitor
LCALL PUTC
;The following code allows me to
;return control to the monitor by typing a period
;This part of the program works just fine. :o)
;copy the character into B
MOV B,A
;Clear the Carry flag
CLR C
;Load A with the period (2Eh)
MOV A,#2Eh
;TEST FOR PERIOD
SUBB A,B
;Return to the Monitor if a period is detected
JZ FINISH
;Otherwise Stay in the program for another input
SJMP LOOP
;back to monitor prompt
FINISH: LJMP 05AH ;
.END
Any help would be appreciated.
If you have a workable character input routine maybe you could just send me the .asm file for that?
Also if anyone has an assembly listing for the Monitor V1.1 program I would also appreciate that.
And finally, I could use an 8051 disassembler
Thanks,
James