⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 btc_asmdemo.asm

📁 ADI 公司的DSP ADSP21262 EZ-KIT LITE开发板的全部源代码
💻 ASM
字号:
/////////////////////////////////////////////////////////////////////////////
//
// Example assembly program using Background Telemetry Channel (BTC)
// Analog Devices 2004
//
// This program defines several BTCs to allow transfer of data over the BTC
// interface while the DSP is running.  Use the BTC Memory window in the
// debugger to view each channels data.  The defined channels are described
// below:
// 
// Timer Interrupt Counter:  This channel is defined to be 1-word (4-bytes)
//		   				     in length and simply counts the number of timer
//							 interrupts that have occured.
//
// Constant Data Value: This channel is defined to be 1-word (4-bytes) in length and
//			            simply displays a constant value that is not changed by the
//                      the running program.
//
// Constant Data Buffer: This channel is defined to be 8-words (32-bytes) in length and
//			            simply displays an array of constant values that are not changed by the
//                      the running program.
//
// Data Array (8kw):  This channel is defined to be 8-kwords in length.  The first word of the
//					  channel is used to count the number of timer interrupts that have occured.
//
// NOTE:  In order for the LEDs to function properly SW8.6 (LED_CS_SW) should be set in the OFF position.
/////////////////////////////////////////////////////////////////////////////

#include "btc.h"
#if defined (__ADSP21262__)
#include "def21262.h"
#endif

#if defined (__ADSP21364__)
#include "def21364.h"
#endif

#define DATA_BUF_SIZE  		8
#define ARRAY_SIZE			0x2000

////////////////////////////
// Variable Definitions
////////////////////////////
.section/DM seg_dmda;

.var timerCounter;
.var dataVal = 0x11223344;
.var dataBuf[DATA_BUF_SIZE] = {0x11223344,0x55667788,0x99aabbcc,0xddeeff00,
                               0x55555555,0x66666666,0x77777777,0x88888888};
.var array1[ARRAY_SIZE];

//////////////////////////
// BTC Definitions
//////////////////////////
BTC_MAP_BEGIN
//             Channel Name,               Starting Address, Length
BTC_MAP_ENTRY('Timer Interrupt Counter',   timerCounter,     0x0001)
BTC_MAP_ENTRY('Constant Data Value',       dataVal,          0x0001)
BTC_MAP_ENTRY('Constant Data Buffer',      dataBuf,          DATA_BUF_SIZE)
BTC_MAP_ENTRY('Data Array (8kw)',          array1,           ARRAY_SIZE)
BTC_MAP_END


///////////////////////////
// Main program
///////////////////////////
.section/PM seg_pmco;

.extern ldf_stack_space;
.extern ldf_stack_length;

.global _main;
_main:

	// init the stack
	b7 = ldf_stack_space;
	i7 = ldf_stack_space + ldf_stack_length - 2;
	m7 = -1;
	l7 = ldf_stack_length - 1;
	
	// initialize array1 with incrementing values
	i0 = array1;
	m0 = 1;
	l0 = 0;
	r0 = 0;
	
	lcntr = ARRAY_SIZE, do INIT_ARRAY until lce;
			dm(i0, m0) = r0;
INIT_ARRAY: r0 = r0 + 1;

	// initialize the different components of the program
	call _btc_init;
			
	call initLEDs;
	call initInterrupts;
	call initTimer;
		
loop1:	
	nop;
	nop;
	jump loop1;
_main.end:
	

//////////////////
//  GPTimer0 ISR
//////////////////
tmr0_isr:
	push sts;				// push status
	dm(i7,m7) = r0;			// push r0
	dm(i7,m7) = ustat1;		// push ustat1

	r0 = dm(timerCounter);
	r0 = r0 + 1;			// increment the timerCounter
	dm(timerCounter) = r0;
	
	dm(array1) = r0;		// write the timerCounter to first location of array1 also
	
	ustat1 = TIM0IRQ;		// clear the timer interrupt status
	dm(TMSTAT) = ustat1;
	
	ustat1 = flags;
	bit tgl ustat1 FLG8;	// toggle LED1 on the EZ-Kit
	flags = ustat1;
	
	ustat1 = dm(1,i7);		// pop ustat1
	r0 = dm(2,i7);			// pop r0
	modify(i7,2);			// fix stack ptr
	pop sts;				// pop status
	
	rti;

/////////////////////////////////////////////
//  used to catch any unexpected interrupts
/////////////////////////////////////////////
bad_isr:
	nop;
	nop;
	nop;
	nop;
	rti;	
	
//////////////
//  initLEDs
//////////////
initLEDs:
	ustat1 = dm(SYSCTL);
	bit set ustat1 PPFLGS;	// disable the parallel port and use AD pins as Flags
	dm(SYSCTL) = ustat1;
	
	// set flag 15-8 as outputs
	bit set flags FLG15O|FLG14O|FLG13O|FLG12O|FLG11O|FLG10O|FLG9O|FLG8O;
	// set flag 15-8 off (turns the LEDs off)
	bit clr flags FLG15|FLG14|FLG13|FLG12|FLG11|FLG10|FLG9|FLG8;
		
	rts;
	
////////////////////
//  initInterrupts
////////////////////
initInterrupts:
	// setup imask, enable gptimer0 and low-priority emulator interrupt
	ustat1 = imask;
	bit set ustat1 GPTMR0I | EMULI;
	imask = ustat1;
	
	// enable interrupts
	ustat1 =  mode1;
	bit set ustat1 IRPTEN;
	mode1 = ustat1;	
	
	rts;
	
///////////////
//  initTimer
///////////////
initTimer:
	// configure timer 0
	r0 = TIMODEPWM | PRDCNT | IRQEN;
	dm(TM0CTL) = r0;
	
	// timer period
	r0 = 0x00800000;
	dm(TM0PRD) = r0;
	
	// timer width
	r0 = 1;
	dm(TM0W) = r0;
	
	// enable timer 0
	r0 = BIT_8;
	dm(TMSTAT) = r0;
	
	rts;




//////////////////////////////
//  Interrupt Vector Table
//////////////////////////////
.section/PM seg_rth;

emui:
	nop;nop;nop;nop;
rsti:
	nop;nop;nop;jump _main;
iicdi:
	nop;nop;nop;jump bad_isr;
sovfi:
	nop;nop;nop;jump bad_isr;
tmzhi:
	nop;nop;nop;jump bad_isr;
//rsvd
	nop;nop;nop;nop;
bkpi:
	nop;nop;nop;jump bad_isr;
//rsvd
	nop;nop;nop;nop;
irq2i:
	nop;nop;nop;jump bad_isr;
irq1i:
	nop;nop;nop;jump bad_isr;
irq0i:
	nop;nop;nop;jump bad_isr;
daihi:
	nop;nop;nop;jump bad_isr;
spihi:
	nop;nop;nop;jump bad_isr;
gptmr0i:
	nop;nop;nop;jump tmr0_isr;
sp1i:
	nop;nop;nop;jump bad_isr;
sp3i:
	nop;nop;nop;jump bad_isr;
sp5i:
	nop;nop;nop;jump bad_isr;
sp0i:
	nop;nop;nop;jump bad_isr;
sp2i:
	nop;nop;nop;jump bad_isr;
sp4i:
	nop;nop;nop;jump bad_isr;
ppi:
	nop;nop;nop;jump bad_isr;
gptmr1i:
	nop;nop;nop;jump bad_isr;
//rsvd
	nop;nop;nop;nop;
daili:
	nop;nop;nop;jump bad_isr;
//rsvd
	nop;nop;nop;nop;
//rsvd	
	nop;nop;nop;nop;
//rsvd
	nop;nop;nop;nop;
//rsvd
	nop;nop;nop;nop;
gptmr2i:
	nop;nop;nop;jump bad_isr;
spili:
	nop;nop;nop;jump bad_isr;
cb7i:
	nop;nop;nop;jump bad_isr;
cb15i:
	nop;nop;nop;jump bad_isr;
tmzli:
	nop;nop;nop;jump bad_isr;
fixi:
	nop;nop;nop;jump bad_isr;
fltoi:
	nop;nop;nop;jump bad_isr;
fltui:
	nop;nop;nop;jump bad_isr;
fltii:
	nop;nop;nop;jump bad_isr;
emuli:
	nop;nop;nop;jump _btc_isr;
sft0i:
	nop;nop;nop;jump bad_isr;
sft1i:
	nop;nop;nop;jump bad_isr;
sft2i:
	nop;nop;nop;jump bad_isr;
sft3i:
	nop;nop;nop;jump bad_isr;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -