English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

clr TR1 ; Stop timer 1
mov a,#0FH ; Set timer 1 as 8-bit autoreload timer
anl a,TMOD
orl a,#20H
mov TMOD,a
orl PCON,#80H ; SMOD=1 -> k=2: double baudrate
mov TL1,#0FFH ; Set baud rate to 115200 for 22.1184MHz crystal
mov TH1,#0FFH
setb TR1 ; Start timer 1
mov SCON,#52H ; Serial port in mode 1, ren, txrdy, rxempty
ret

2007-02-07 19:20:48 · 1 answers · asked by Princess Jasmine 2 in Computers & Internet Programming & Design

1 answers

clr TR1 ; Stop timer 1
;clear TR1 bit

mov a,#0FH; VALUE TO CLEAR TIMER 1 SETTINGS
;move the value 0f hex to the accumulator

anl a,TMOD ; BASICALLY, CLEARS THE TIMER 1 SETTINGS
;"and" the contents of TMOD with the accumulator

orl a,#20H ;THIS LINE SETS THE TIMER FOR 8-BIT TIMER
;"or" the value 20 hex with the accumulator

mov TMOD,a ;SAVE THE SETTINGS TO TMOD
;move the accumulator to the TMOD register

orl PCON,#80H ; SMOD=1 -> k=2: double baudrate
;"or" the value 80 hex with the PCON register

mov TL1,#0FFH ; Set baud rate to 115200 for 22.1184MHz
crystal
;move the value ff hex to TL1 register

mov TH1,#0FFH;SET THE AUTO RELOAD VALUE
;move the value ff hex to the TH1 register

setb TR1 ; Start timer 1
'set bit TR1

mov SCON,#52H ; Serial port in mode 1, ren, txrdy, rxempty
;move the value 52 hex to the SCON register

ret; DONE
;return

Basically, it is setting up the serial port for a baud rate of 115200, using timer 1 as the baud rate timer. TL1 is the counter and TH1 is used to reload TL1 when it overflows and gives the interrupt.

2007-02-08 01:23:03 · answer #1 · answered by justme 7 · 0 0

fedest.com, questions and answers