C-16 – Texas Instruments TMS320C2XX User Manual

Page 501

Advertising
background image

Task-Specific Program Code

C-16

Example C–11. Testing and Using Automatic Baud-Rate Detection on

Asynchronous Serial Port (autobaud.asm)

* File:

autobaud.asm

*

* Function:

UART,auto baud test

*

*

Locks to incoming baud rate if the first character

*

*

is ”A” or ”a” & continuously echoes data received

*

*

through the port.

*

* Once detection is complete, if the CAD and ADC bits are not

*

* disabled and the interrupt is enabled, the ISR will occur for

*

* all characters received and will change the baud setting again.

*

.title ”Auto_baud detect”

; Title

.copy

”init.h”

; Variable and register declaration

.copy

”vector.h”

; Vector label declaration

.text

start:

clrc

CNF

; Map block B0 to data memory

ldp

#0h

; set DP=0

setc

INTM

; Disable all interrupts

* UART initialization *

splk

#0ffffh,ifr

; clear interrupts

splk

#0000h,60h

out

60h, wsgr

; Set zero wait states

splk

#0c0a0h,61h

; reset the UART by writing 0

out

61h, aspcr

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

splk

#0e0a0h,61h

; CAD=1 enable

out

61h,aspcr

splk

#4fffh,62h

; enable ADC bit

out

62h,iosr

; disable auto baud

splk

#0000h, 63h

; set baud rate =0000 @ 20-MHz CLKOUT1

out

63h, brd

splk

#20h,imr

; enable UART interrupt

mar

*,ar1

lar

ar1,#rxbuf

* Load data at DM300

lar

ar1,#rxbuf

lar

ar0, #size

; load buffer size

mar

*,ar1

; load data pointer

clrc

intm

wait:

clrc

xf

idle
b

wait

Advertising