1 $NOPAGING
2 $MOD252
3
0000 4 org 00h
5
0000 75A000 6 mov p2,#00H
0003 7404 7 MOV A, #04h ; 9600bps ..
0005 120012 8 LCALL Ser_Setup
9
0008 10 scan:
0008 3098FD 11 jnb ri,$
000B 8599A0 12 mov p2,sbuf
000E C298 13 clr ri
0010 80F6 14 jmp scan
15
16 ; =====================================================================
17 ; Initialize Serial communications A=Baud Rate
18 ; With cristal oscillator of 11,059,200 value for auto-reloded Timer1 is calculated using the
19 ; following formula: 256-57600/BaudRate=TH1
20 ; Full formula: 256-[2pwrSMOD/32]*[SC/(12*BaudRate)]
21
0012 22 Ser_Setup:
0012 758780 23 MOV PCON, #80h
0015 759852 24 MOV SCON, #52h
0018 758920 25 MOV TMOD, #20h
001B 900024 26 SetNewBaud: MOV DPTR, #BAUDRATE
001E 93 27 MOVC A, @A+DPTR
001F F58D 28 MOV TH1, A
0021 D28E 29 SETB TR1
0023 22 30 RET
31
0024 FF 32 BAUDRATE: DB 0FFh ; 57600 0
0025 FE 33 DB 0FEh ; 28800 1
0026 FD 34 DB 0FDh ; 19200 2
0027 FC 35 DB 0FCh ; 14400 3
0028 FA 36 DB 0FAh ; 9600 4
0029 F4 37 DB 0F4h ; 4800 5
002A E8 38 DB 0E8h ; 2400 6
002B D0 39 DB 0D0h ; 1200 7
002C A0 40 DB 0A0h ; 600 8
002D 40 41 DB 040h ; 300 9
42
43
44 ; ====================================================================
45
46 end
VERSION 1.2h ASSEMBLY COMPLETE, 0 ERRORS FOUND
BAUDRATE . . . . . . . . . . . . C ADDR 0024H
P2 . . . . . . . . . . . . . . . D ADDR 00A0H PREDEFINED
PCON . . . . . . . . . . . . . . D ADDR 0087H PREDEFINED
RI . . . . . . . . . . . . . . . B ADDR 0098H PREDEFINED
SBUF . . . . . . . . . . . . . . D ADDR 0099H PREDEFINED
SCAN . . . . . . . . . . . . . . C ADDR 0008H
SCON . . . . . . . . . . . . . . D ADDR 0098H PREDEFINED
SER_SETUP. . . . . . . . . . . . C ADDR 0012H
SETNEWBAUD . . . . . . . . . . . C ADDR 001BH NOT USED
TH1. . . . . . . . . . . . . . . D ADDR 008DH PREDEFINED
TMOD . . . . . . . . . . . . . . D ADDR 0089H PREDEFINED
TR1. . . . . . . . . . . . . . . B ADDR 008EH PREDEFINED