188
CHAPTER 10 8-Bit Serial I/O
MB89960 series
10.10 Program Examples for 8-Bit Serial I/O
This section gives program examples for 8-bit serial I/O.
s Program Example for Serial Output
q Processing description
This example outputs 8 bits of serial data (55H) from the SO pin of serial I/O, then
generates an interrupt when transfer is complete.
The interrupt processing routine sets the next transfer data and continues output.
Serial I/O uses an internal shift clock and outputs the shift clock from the SCK pin.
For a 10 MHz source oscillation and the shift clock set to 32tinst, the transfer speed and
interrupt generation period are as follows:
Transfer speed = 10 MHz/4/32 = 78.125 kbps
Interrupt period = 4 x 32 x 8/10 MHz = 102.4
s
q Coding example
SMR
EQU
001CH
;Serial mode register 1
SDR
EQU
001DH
;Serial data register 1
SIOF
EQU
SMR:7
;Defines the interrupt request flag bit.
SST
EQU
SMR:0
;Defines the serial I/O transfer start bit.
ILR2
EQU
007DH
;Address of interrupt level setting register 2
INT_V
DSEG
ABS
;[DATA SEGMENT]
ORG
0FFECH
IRQ4
DW
WARI
;Set interrupt vector.
INT_V
ENDS
:-----Main program----------------------------------------------------------------------------------------------------------------------------------------
CSEG
;[CODE SEGMENT]
;Stack pointer (SP) etc. are already initialized.
:
CLRI
;Disable interrupts.
CLRB
SST
;Halt serial I/O transfer.
MOV
ILR2,#11111101B
;Set interrupt level (level 2).
MOV
SDR1,#55H
;Set transfer data (55H).
MOV
SMR1,#01111000B
;Clear interrupt request flag, enable output of interrupt requests,
;enable shift clock output (SCK), enable serial data output (SO),
;select 32tinst, select LSB-first, and
SETB
SST
;start serial I/O transfer.
SETI
;Enable interrupts.
:
;-----Interrupt processing routine----------------------------------------------------------------------------------------------------------------------
WARI
CLRB
SIOF
;Clear interrupt request flag.
PUSHW
A
XCHW
A,T
;Save A and T.
PUSHW
A
MOV
SDR1,#55H
;Reset transfer data (55H).
SETB
SST
;Start serial I/O transfer.
:
User processing
:
POPW
A
XCHW
A,T
;Restore A and T.
POPW
A
RETI
ENDS
;---------------------------------------------------------------------------------------------------------------------------------------------------------------
END