Download TMS320F/C240 DSP Controller

Transcript
SCI Initialization Example
8.7 SCI Initialization Example
Example 8–1. Asynchronous Communication Routine
;***********************************************************************
; File Name:
TMS320x240 SCI Idle–line Mode Example Code
;
; Description: This program uses the SCI module to implement a simple
;
asynchronous communications routine. The SCI is
;
initialized to operate in idle–line mode with 8 character
;
bits, 1 stop bit, and odd parity. The SCI Baud Rate
;
Registers (BRR) are set to transmit and receive data at
;
19200 baud. The SCI generates an interrupt every time a
;
character is loaded into the receive buffer (SCIRXBUF).
;
The interrupt service routine(ISR) reads the receive
;
buffer and determines if the carriage return button, <CR>,
;
has been pressed. If so, the character string ”Ready” is
;
transmitted. If not, no character string is transmitted.
;***********************************************************************
; SET statements for ’24x devices are device dependent. The SET
; locations used in this example are typically true for devices with
; only one SCI module. Consult the device data sheet to determine the
; exact memory map locations of the modules you will be accessing
; (control registers, RAM, ROM).
;
.include ”c240reg.h”
; contains a list of SET statements
; for all registers on TMS320x240.
; The following SET statements for the SCI are contained in c240reg.h
; and are shown explicitly for clarity.
;Serial Communications Interface (SCI) Registers
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SCICCR
.set
07050h
;SCI Comms Control Reg
SCICTL1
.set
07051h
;SCI Control Reg 1
SCIHBAUD
.set
07052h
;SCI Baud rate control
SCILBAUD
.set
07053h
;SCI Baud rate control
SCICTL2
.set
07054h
;SCI Control Reg 2
SCIRXST
.set
07055h
;SCI Receive status reg
SCIRXEMU
.set
07056h
;SCI EMU data buffer
SCIRXBUF
.set
07057h
;SCI Receive data buffer
SCITXBUF
.set
07059h
;SCI Transmit data buffer
SCIPC2
.set
0705Eh
;SCI Port control reg2
SCIPRI
.set
0705Fh
;SCI Priority control reg
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
; Constant definitions
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
LENGTH
.set
00005h
; length of the data stream to be
; transmitted
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
; Variable definitions
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
.bss
DATA_OUT,LENGTH ; Location of LENGTH byte character
; stream to be transmitted
.bss
GPR0,1
;General purpose register.
8-34