beautypg.com

Texas Instruments TMS320C2XX User Manual

Page 500

background image

Task-Specific Program Code

C-15

Program Examples

Example C–10. Loopback to Verify Transmissions of Asynchronous Serial Port (echo.asm)

(Continued)

* UART initialization *

splk

#0ffffh,ifr

; clear interrupts

splk

#0000h,60h

out

60h, wsgr

; Set zero wait states

splk

#0c080h,61h

; reset the UART by writing 0

out

61h, aspcr

; 1 stop bit, rx interrupt, input i/o

splk

#0e080h,61h

out

61h,aspcr

splk

#4fffh,62h

out

62h,iosr

; disable auto baud

splk

#0411h, 63h

; set baud rate =1200 @ 20MHz CLKOUT1

out

63h, brd

splk

#20h,imr

; enable UART interrupt

mar

*,ar1

* Load data at DM300

lar

ar1,#rxbuf

lar

ar0, #size

; load buffer size

mar

*,ar1

; load data pointer

clrc intm

wait:

clrc

xf

; toggle xf bit

idle
b

wait

uart:

setc

xf

; toggle xf bit
; Check receive flag bit in iosr

in

68h,iosr

; load input status from iosr

bit

68h,7

; bit 8 in the data

bcnd

skip,ntc

; IF DR=0 no echo, return

in

*,adtr

; read and save at 300h

out

*+,adtr

; echo

mar

*,ar0

banz

skip,ar1

; check if size=0, and reload

lar

ar1,#rxbuf

lar

ar0,#size

skip:

splk

#0020h, ifr

; Clear interrupt in ifr!

clrc

intm

ret

inpt1:

ret

inpt23:

ret

timer:

ret

codtx:

ret

codrx:

ret
.end

; Assembler module end directive
; –optional