📄 delay.asm
字号:
***********************************************************************
*Copyright (c) 2006, dsplab.cuit
*All rights reserved
*File: delay.asm
*
*循环与延时程序
*该程序的功能可使接在F206的XF,IO2引脚上的发光二极管(红、绿灯)交替闪烁,
*闪烁间隔为2s(亮2s,灭2s),闪烁总时间为2min
*程序中用到了用DSP实现的延时模块。该模块是采用指令延时来实现的,这在很多
*程序中都可以用到,但在严格的情况下应使用定时器产生延时以提高精度和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 ;设置2min循环次数30次
splk #0ffffh,60h ; Inner repeat loop size
loop: setc xf ; xf=1 红灯亮
out 6fh,IOSR ;bit2=0 绿灯灭
call delay ;调用2s延时子程序
clrc xf ; xf=0 红灯灭
out 6eh,IOSR ;bit2=1 绿灯亮
call delay
mar *,ar1 ; Set ARP to ar1
banz loop ;ar1 != 0时跳转到loop,(ar1)-1 -->ar1
wait: b wait ;ar1=0结束
delay: lar ar0,#609 ;设置2s循环次数610次
mar *,ar0
loop1: rpt 60h ;nop指令执行0ffffh+1次
nop
banz loop1 ;ar0 != 0时跳转到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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -