?? btc_asmdemo.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.
//
/////////////////////////////////////////////////////////////////////////////
#include "btc.h"
#ifdef __ADSP21375__
#include "def21375.h"
#elif __ADSP21369__
#include "def21369.h"
#endif
#include <SRU.h>
#define DATA_BUF_SIZE 8
#ifdef __ADSP21375__
#define ARRAY_SIZE 0x0AAA
#define DATA_ARRAY_STRING 'Data Array (2kw)'
#elif __ADSP21369__
#define ARRAY_SIZE 0x2000
#define DATA_ARRAY_STRING 'Data Array (8kw)'
#endif
////////////////////////////
// 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_STRING, 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 = dm(1,i7); // pop ustat1
r0 = dm(2,i7); // pop r0
modify(i7,2); // fix stack ptr
pop sts; // pop status
nop;
bit tgl flags FLG4; //light LED 1,2,3,4,5, & 8.
rti;
/////////////////////////////////////////////
// used to catch any unexpected interrupts
/////////////////////////////////////////////
bad_isr:
nop;
nop;
nop;
nop;
rti;
//////////////
// initLEDs
//////////////
initLEDs:
SRU(FLAG6_O,DPI_PB08_I); // Connect Flag6 output to DPI_PB08 input (LED3)
SRU(FLAG7_O,DPI_PB13_I); // Connect Flag7 output to DPI_PB13 input (LED4)
SRU(FLAG4_O,DPI_PB06_I); // Connect Flag4 output to DPI_PB06 input (LED1)
SRU(FLAG5_O,DPI_PB07_I); // Connect Flag5 output to DPI_PB07 input (LED2)
SRU(FLAG8_O,DPI_PB14_I); // Connect Flag8 output to DPI_PB14 input (LED5)
SRU(LOW,DAI_PB15_I); // Connect Input LOW to LED6
SRU(LOW,DAI_PB16_I); // Connect Input LOW to LED7
//Enabling the Buffer using the following sequence: High -> Output, Low -> Input
SRU(HIGH,DPI_PBEN08_I);
SRU(HIGH,DPI_PBEN13_I);
SRU(HIGH,DPI_PBEN06_I);
SRU(HIGH,DPI_PBEN07_I);
SRU(HIGH,DPI_PBEN14_I);
SRU(HIGH,DPI_PBEN01_I);
SRU(HIGH,PBEN15_I);
SRU(HIGH,PBEN16_I);
//Setting flag pins
bit set flags FLG3O|FLG4O|FLG5O|FLG6O|FLG7O|FLG8O;
//Clearing flag pins
bit clr flags FLG3|FLG4|FLG5|FLG6|FLG7|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 + -