C.3 task-specific program code – Texas Instruments TMS320C2XX User Manual

Page 493

Advertising
background image

Task-Specific Program Code

C-8

C.3 Task-Specific Program Code

Example C–4. Implementing Simple Delay Loops (delay.asm)

* File:

delay.asm

*

* Function:

Delay loop. XF and I/O 3 pins toggle after each delay

*

.title ”Delay routine”

; 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

splk

#0000h, 60h

; Set zero wait states

out

60h, wsgr

splk

#0e00ch,60h

; Define iosr for bit I/O in aspcr

out

60h,aspcr

lar

ar0,#del

; Initialize ar0

mar

*,ar7

; Set ARP to ar7

splk

#0008h,6eh

; data for setting bit I/O 3

splk

#0000h,6fh

; data for clearing bit I/O 3

splk

#0ffffh,60h

; Inner repeat loop size

lar

ar7,#del

loop:

clrc

xf

; xf=0

out

6fh,iosr

; bit 3=0

dely1:

rpt

60h

; @ 50ns, this loop gives 3.4 ms approx.

nop
banz

dely1,ar7

; delay = 17*3.4 = 57.8 ms approx.

lar

ar7,#del

setc

xf

; xf=1

out

6eh,iosr

; bit 3=1

dely2:

rpt

60h

; @ 50ns, this loop gives 3.4 ms approx.

nop
banz

dely2,ar7

; delay = 17*3.4 = 57.8 ms approx.

lar

ar7,#del

b

loop

inpt1:

ret

; Unused interrupts

inpt23:

ret

; have dummy returns for safety

timer:

ret

uart:

ret

codtx:

ret

codrx:

ret
.end

; Assembler module end directive –optional

Advertising