?? delay.asm
字號(hào):
***********************************************************************
*Copyright (c) 2006, dsplab.cuit
*All rights reserved
*File: delay.asm
*
*循環(huán)與延時(shí)程序
*該程序的功能可使接在F206的XF,IO2引腳上的發(fā)光二極管(紅、綠燈)交替閃爍,
*閃爍間隔為2s(亮2s,滅2s),閃爍總時(shí)間為2min
*程序中用到了用DSP實(shí)現(xiàn)的延時(shí)模塊。該模塊是采用指令延時(shí)來(lái)實(shí)現(xiàn)的,這在很多
*程序中都可以用到,但在嚴(yán)格的情況下應(yīng)使用定時(shí)器產(chǎn)生延時(shí)以提高精度和CPU效率。
*
* Author: Chen Ziwei
***********************************************************************
.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 #0e005h,60h ; #0e00ch ;Define iosr for bit I/O in aspcr
out 60h,ASPCR
splk #0004h,6eh ; data for setting bit I/O 2
splk #0000h,6fh ; data for clearing bit I/O 2
lar ar1,#29 ;設(shè)置2min循環(huán)次數(shù)30次
splk #0ffffh,60h ; Inner repeat loop size
loop: setc xf ; xf=1 紅燈亮
out 6fh,IOSR ;bit2=0 綠燈滅
call delay ;調(diào)用2s延時(shí)子程序
clrc xf ; xf=0 紅燈滅
out 6eh,IOSR ;bit2=1 綠燈亮
call delay
mar *,ar1 ; Set ARP to ar1
banz loop ;ar1 != 0時(shí)跳轉(zhuǎn)到loop,(ar1)-1 -->ar1
wait: b wait ;ar1=0結(jié)束
delay: lar ar0,#609 ;設(shè)置2s循環(huán)次數(shù)610次
mar *,ar0
loop1: rpt 60h ;nop指令執(zhí)行0ffffh+1次
nop
banz loop1 ;ar0 != 0時(shí)跳轉(zhuǎn)到loop1,(ar0)-1 -->ar0
ret
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
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -