398
CHAPTER 13 UART
MB90560 series
13.9 Sample Program for UART
This section contains a sample program for UART.
I
Sample Program for UART
G
Processing Specifications
The UART1 bidirectional communication function (normal mode) is used to perform serial
transmission and reception.
Operation mode 0, asynchronous mode, eight data bits, two stop bits, and no parity are set.
The P60/SIN1 and P61/SOT1 pins are used for communication.
The dedicated baud rate generator is used and the baud rate is set to about 9600 bps.
Character 13H is transmitted from the SOT1 pin and is received using an interrupt.
The machine clock (
φ
) is assumed to be 16 MHz.
G
Coding Example
ICR13
ICR13
DDR3
SMR1
SCR1
SIDR1
SSR1
SODR1
REC
;-------Main program------------------------------------------------------------------------------------------------
CODE
CSEG
ABS = 0FFH
START:
;
:
;
;
AND
CCR,#0BFH
;
MOV
I:ICR13,#00H
;
MOV
I:DDR3,#00000000B
;
MOV
I:SMR1,#00000001B
;
;
;
MOV
I:SCR1,#00010011B
;
;
;
MOV
I:SSR1,#00000010B
;
;
MOV
I:SODR1,#13H
;
MOV
ILM,#07H
;
OR
CCR,#40H
;
LOOP:
MOV
A,#00H
;
MOV
A,#01H
BRA
LOOP
;-------Interrupt program-------------------------------------------------------------------------------------------
WARI:
MOV
A,SIDR1
;
CLRB
I:REC
;
;
:
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
0000BDH
0000BDH
000013H
000024H
000025H
000026H
000026H
000027H
SCR1:2
;
;
;
;
;
;
;
;
;
UART1 transmission interrupt control register
UART1 reception interrupt control register
Port-3 data direction register
Mode control register 1
Control register 1
Input data register 1
Output data register 1
Status register 1
Reception error flag clear bit
Assumes that stack pointer (SP) has already been
initialized.
Disables interrupts.
Interrupt level 0 (highest)
Sets SIN0 pin as input pin
Operation mode 0 (asynchronous)
Uses dedicated baud rate generator (9615 bps)
Disables clock pulse output and enables data output.
No parity and two stop bits
Clears eight data bits and reception error flag.
Enables transmission and reception operations.
Disables transmission interrupts and enables reception
interrupts.
Writes transmission data.
Sets ILM in PS to level 7.
Enables interrupts.
Endless loop
Reads receive data.
Clears reception interrupt request flag.