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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/25/00 11:47
Read: times


 
#2329 - RE: serial port initialization
Hello Eric,

This is my code;

;******************
;Hard-Code Textstrings
;******************
cseg at 100h;
txthello:
db 'Program Ready V1 (c) E. Salavarez',13,10,232,00

;*********************
;Setup Serial Communication
;*********************

Mov tmod,#00100000b
;Setup Timer1 as baudrategenerator TimerMode=2 (auto-reload)
Mov PCON,#10000000b
;Smod = 1
Mov TH1,#250
;baudrate = 11059200 / (6*32*(256-TH1)) = 9600
setb tr1
;Start Timer1 for running for Serial communication
setb sm1
;set Serial port to mode1 : 8-Bit Uart
clr ri
;Clear Interrup receive flag (set when a byte is received)
clr ti
;Clear Interrup transmit flag (set when a byte is transmitted)
setb ren
;Enables serial reception.

;*******************
;Say hello to the terminal
;*******************
Mov dptr,#txthello
call sstr ;Send string to terminal
end

;**************************************
;Routine to send a string via serial communication
;Datapointer is loaded with position of first byte
;**************************************

sstr: Mov a,#00 ;clear relative pointer
sstr0: Movc a,@a+dptr ;read a byte
inc dptr ;increment datapointer
jnz sstr1 ;if it wasn't a then send this byte (sstr1)
ret ;else finish the routine
;Send one byte of the string
sstr1: clr ren ;No receiving alowed till this byte is transmitted
Mov sbuf,a ;Write byte to the serial port
sstr2: jnb ti,sstr2 ;Wait till it is delivered
clr ti ;Clear Transmit-interrupt-flag
jmp sstr ;next byte



List of 4 messages in thread
TopicAuthorDate
serial port initialization            01/01/70 00:00      
RE: serial port initialization            01/01/70 00:00      
RE: serial port 8052ah-basic version 1.1            01/01/70 00:00      
RE: serial port 8052ah-basic version 1.1            01/01/70 00:00      

Back to Subject List