The Serial Interface
PHYTEC Meßtechnik GmbH 1993 L-006e_2
41
6.8
Program Example for the Serial Interface
The given examples use no interface interrupts, but test only the
interface flags RI and TI.
6.8.1
Program for SERIAL0
; Example of the initialization for the utilization of the
; internal baud rate generator for 12 MHz system-clock frequency.
init: setb
BD
; Select internal BD-generator
orl
PCON,#80H
; Set bit SMOD for 9600 baud
; Alternative: anl PCON,#7FH for 4800
; baud
mov S0CON,#5AH
; Mode-adjustment and initialization
; of the flags RI0 and TI0 8
; data bit, no parity, 1 start bit,
; 1 stop bit TI0 set, RI0 erased.
init_end:
...
...
; Example of the initialization for the utilization of timer 1
; as baud rate generator for a system-clock frequency
; of 11.059 MHz.
ch0_in:
; Subroutine to read a character
jnb RI0,ch_in
; Wait until character accepted
clr RI0
mov a,S0BUF
ret
; character in ACC
ch0_out:
; Subroutine to output a character
; Output character in ACC
jnb TI0,ch_out
; Wait until ready for transmission
clr TI0,ch_out
mov S0BUF,a
ret
init: clr BD
; not necessary after a RESET
anl TMOD,#0FH
orl TMOD,#20H
; Mode 8 bit, autoreload
orl PCON,#80H
; Set bit SMOD Baud
; Alternative: anl PCON,#7FH
mov TH1,#232
; Reload value for 2400 baud for SMOD=1
setb TR1
; Start timer 1
movb S0CON,#5AH
; Mode adjustment and initialization of
; flags RI0 and TI0 8 data bit, no
; parity, 1 start bit, 1 stop bit set
; TI0, Erase RI0
init_end:
...
Summary of Contents for miniMODUL-537
Page 6: ...miniMODUL 537 PHYTEC Me technik GmbH 1993 L 006e_2...
Page 38: ...miniMODUL 537 32 PHYTEC Me technik GmbH 2001 L 006e_2...
Page 52: ...miniMODUL 537 46 PHYTEC Me technik GmbH 2001 L 006e_2...
Page 56: ...miniMODUL 537 50 PHYTEC Me technik GmbH 2001 L 006e_2...
Page 58: ...miniMODUL 537 52 PHYTEC Me technik GmbH 2001 L 006e_2...
Page 66: ...Published by PHYTEC Me technik GmbH 2001 Ordering No L xxxe_x Printed in Germany...