11
10.
Program Examples for 8-bit Serial I/O
This section gives program examples for 8-bit serial I/O.
n Program Example for Serial Output
l
Processing description
•
Outputs 8 bits of serial data (55H) from the SO1 pin of serial I/O-1, then generates an
interrupt when transfer is completed.
•
The interrupt processing routine resets the transfer data and continues output.
•
Operates as an internal shift clock and outputs the shift clock from the SCK1 pin.
•
For a 10 MHz (1 instruction cycle = 4/F
32 t
Coding example
l
SMR1
SDR1
SIOF
SST
ILR2
INT_V
IRQ7
INT_V
:-----Main program----------------------------------------------------------------------------------------------------------------------------------------
;-----Interrupt processing routine----------------------------------------------------------------------------------------------------------------------
WARI
;---------------------------------------------------------------------------------------------------------------------------------------------------------------
222
CHAPTER 10 8-BIT SERIAL I/O (SERIAL I/O-1 AND SERIAL I/O-2)
the transfer speed and interrupt generation cycle are as follows:
inst
Transfer speed = 10 MHz/4/32 = 78.125 kbps
Interrupt cycle = 8 × 32 × 4/10 MHz = 102.4 µ s
EQU
001CH
EQU
001DH
EQU
SMR1:7
EQU
SMR1:0
EQU
007DH
DSEG
ABS
ORG
0FFECH
DW
WARI
ENDS
CSEG
:
CLRI
CLRB
SST
MOV
ILR2,#01111111B
MOV
SDR1,#55H
MOV
SMR1,#01111000B
SETB
SST
SETI
:
CLRB
SIOF
PUSHW
A
XCHW
A,T
PUSHW
A
MOV
SDR1,#55H
SETB
SST
:
User processing
:
POPW
A
XCHW
A,T
POPW
A
RETI
ENDS
END
) source oscillation (F
C
C
; Serial 1 mode register
; Serial 1 data register
; Define the interrupt request flag bit.
; Define the serial I/O transfer start bit.
; Address of the interrupt level setting register 2
; [DATA SEGMENT]
; Set interrupt vector.
; [CODE SEGMENT]
; Stack pointer (SP) etc. are already initialized.
; Disable interrupts.
; Stop serial I/O transfer.
; Set interrupt level (level 1).
; Set transfer data (55H).
; Clear interrupt request flag, enable interrupt request output,
enable shift clock output (SCK1), enable serial data output (SO1),
select 32 t
, LSB first.
inst
; Start serial I/O transfer.
; Enable interrupts.
; Clear interrupt request flag.
; Save A and T.
; Reset transfer data (55H).
; Start serial I/O transfer.
; Restore A and T.
) and the shift clock set to
MB89620 series