Download III - Renesas Electronics

Transcript
CHAPTER 8
APPLICATIONS OF SERIAL INTERFACE
<Hardware used>
• Serial interface channel 2 (UART mode)
<Initial setting>
• OSMS=#00000001B
• CLR1 P3.2
; Oscillation mode select register: does not use divider circuit
; P31 = CTS input, P32 = RTS output
PM3=#××××10×B
•
•
•
•
BRGC=#10001011B
; Sets baud rate to 9600 bps (error: 1.14%)
CSIM2=#00000000B
; Sets 0 to serial operation mode register 2 when UART is used
ASIM=#11001101B
; Sets asynchronous serial interface mode register
CLR1 SRIF
; Clears reception end receive error interrupt request flags
CLR1 SERIF
• SET1 STIF
• CLR1 SRMK
; Sets transmission end interrupt request flag (to end transmission)
; Enables reception end and receive error interrupts
CLR1 SERMK
Caution Before starting transmission, check the transmission end interrupt request flag (STIF) so
that transmission is not executed during transmission. Therefore, set the transmission
end interrupt request flag (STIF) after reset and start.
Remark To use the transmission end interrupt (to generate the interrupt request), use an additional flag.
Set the additional flag as the initial setting. Clear the flag at the start of transmission, and set
it in the interrupt processing.
<Starting>
Store the transmit data to the SOSHIN area at the start of transmission and call the S_SOSHIN routine.
291