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

📄 blink with external memory.asm

📁 ADI 公司的DSP ADSP21262 EZ-KIT LITE开发板的全部源代码
💻 ASM
字号:
///////////////////////////////////////////////////////////////////////////////////////
//NAME:     Blink with External Memory.asm
//DATE:     9/18/03
//PURPOSE:  Program to test each memory type for the ADSP-21262 Ez-kit
//
//USAGE:    Contains variable declarations for all possible types of memory that can be
//          used on the ADSP-21262 EZ-kit. It then reads in the external memory buffers
//          that were initialized for verification. Finally it blinks the flags to
//          indicate that the memory reads have completed.
////////////////////////////////////////////////////////////////////////////////////////
#include <def21262.h>
#define BUFLEN 100

// ******************************************************************
//  DM
.section/dm seg_dm64;
    .var dmsixtyfour[] = 0x01234567, 0x12341234, 0xabcdabcd, 0x11112222, 0x643333aa, 0x643333bb ;
        .var dmsixtyfourzeros[] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;

.section/DATA64 seg_6464;
    .var dm6464z[] = 0,0,0,0,0;
    .var dm6464[] = 0xAAAABBBBCCCCDDDD, 0x1111222233334444, 0x6464333364643333;


.section/dm seg_dm40;
    .var dmfourtyzeros[] = 0,0,0,0,0;
    .var dmfourty[] = 0xd401111111, 0xd402222222, 0xd403333333;

.section/dm seg_dm32;
    .var dmthirty[] = 0xD3211111, 0xD3222222, 0xd3233333, 0xd3244444, 0xd3255555;
    .var dmthirtyzeros[] = 0,0,0,0,0;
    .var ext8holder[5];
    .var ext8zerosholder[BUFLEN-5];
    .var LED_value;

.section/dm seg_dm16;
    .var dmsixteenzeros[] = 0,0,0,0,0;
    .var dmsixteen[] = 0xd161, 0xd162, 0xd163, 0xd164, 0xd165;
// ******************************************************************

// ******************************************************************
//  External

.section/dm/dmaonly seg_ext8;
    .var ext8zeros[BUFLEN-5];
    .var ext8[5] = 0xE0811111, 0xE0822222, 0xE0833333, 0xE0844444, 0xE0855555;


// ******************************************************************
//  PM

.section/pm seg_pm64;
    .var pmsixtyfour[] = 0xC0DE6464, 0xC0DE6464, 0xC0DE6464, 0xC0DE6464, 0x6464333a, 0x6464333b;
        .var pmsixtyfourzeros[] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;

.section/pm seg_pmco;
    //These buffers will be accessed via PP DMA which requires an internal address in terms of 32-bit words.
    //Align to an even boundary for easy access with a 32-bit word address
    .align 2;
    .var extpm8holder[6];
    .align 2;
    .var extpm8zerosholder[BUFLEN-4];

.section/pm seg_pm40;
    .var pmfourtyzeros[] = 0,0,0,0,0;
    .var pmfourty[] = 0xC0DE40111100, 0xC0DE40222200, 0xC0DE40333300;

.section/pm seg_pm32;
    .var pmthirtyzeros[] = 0,0,0,0,0;
    .var pmthirty[] = 0xC0DE1111, 0xC0DE2222, 0xC0DE3333, 0xC0DE4444, 0xC0DE5555;

.section/pm seg_pm16;
    .var pmsixteenzeros[] = 0,0,0,0,0;
    .var pmsixteen[] = 0x1234, 0xabcd, 0x1111, 0xcafe, 0xc0de;

// ******************************************************************
//  External

.section/pm/dmaonly seg_extpm8;
    //If external PM buffers are not of even length, special must be taken
    //for parallel port DMA to finish correctly. There must always be an
    //even number of 32-bit words for the status to indicate completion.
    .var extpm8zeros[BUFLEN-4];
    .var extpm8[6] = 0xC0DE48E11111, 0xC0DE48E22222, 0xC0DE48E33333,
                     0xC0DE48E44444, 0xC0DE48E55555, 0xC0DE48E66666;


// ******************************************************************
.global _main;

//Main code section
.section/pm seg_pmco;
_main:
//Enable the Parallel Port interrupt.
bit set lirptl PPIMSK;
bit set mode1 IRPTEN;

//Read in the External DM sections on variable at a time
r4=0;
dm(PPCTL)=r4;
r0=ext8holder;
dm(IIPP)=r0;
r0=1;
dm(IMPP)=r0;
dm(EMPP)=r0;
r0=@ext8holder;
dm(ICPP)=r0;
//Calculate the correct location of the external buffer
//(The symbol manager does not correctly calculate external locations)
r0=(ext8&0xFFFFFC00)|((0x3FF&ext8)*4);   dm(EIPP)=r0;
//External Count is 4x the internal count
r0=@ext8*4;  dm(ECPP)=r0;
ustat1= PPBHC|PPDUR4|PPEN|PPDEN;
dm(PPCTL)=ustat1; nop;

idle;

r0=0;
dm(PPCTL)=r0;
r0=ext8zerosholder;
dm(IIPP)=r0;
r0=1;
dm(IMPP)=r0;
dm(EMPP)=r0;
r0=@ext8zerosholder;
dm(ICPP)=r0;
//Calculate the correct location of the external buffer
//(The symbol manager does not correctly calculate external locations)
r0=(ext8zeros&0xFFFFFC00)|(0x3FF&(ext8zeros*4));   dm(EIPP)=r0;
//External Count is 4x the internal count
r0=@ext8zeros*4;  dm(ECPP)=r0;
ustat1= PPBHC|PPDUR4|PPEN|PPDEN;
dm(PPCTL)=ustat1; nop;

idle;

r0=0;
dm(PPCTL)=r0;
//PP DMA uses a 32-bit address, convert the 48-bit address to its 32-bit
//equivalent.
r0=(extpm8holder&0xF0000)|(0xFFFF&extpm8holder*3/2);
dm(IIPP)=r0;
r0=1;
dm(IMPP)=r0;
dm(EMPP)=r0;
//Calculate the number of 32-bit words to send.
r0=(@extpm8*3/2);
dm(ICPP)=r0;
//Calculate the correct location of the external buffer
//(The symbol manager does not correctly calculate external locations)
r0=(extpm8&0xFFFFFC00)|((0x3FF&extpm8)*6);   dm(EIPP)=r0;
//External Count is 6x the internal count
r0=@extpm8*6;  dm(ECPP)=r0;
ustat1= PPBHC|PPDUR4|PPEN|PPDEN;
dm(PPCTL)=ustat1; nop;

idle;

r0=0;
dm(PPCTL)=r0;
//PP DMA uses a 32-bit address, convert the 48-bit address to its 32-bit
//equivalent.
r0=(extpm8zerosholder&0xF0000)|(extpm8zerosholder*3/2);
dm(IIPP)=r0;
r0=1;
dm(IMPP)=r0;
dm(EMPP)=r0;
//Calculate the number of 32-bit words to send.
r0=(@extpm8zerosholder*3/2);
dm(ICPP)=r0;
//Calculate the correct location of the external buffer
//(The symbol manager does not correctly calculate external locations)
r0=(extpm8zeros&0xFFFFFC00)|((0x3FF&extpm8zeros)*6);   dm(EIPP)=r0;
//External Count is 6x the internal count
r0=@extpm8zeros*6;  dm(ECPP)=r0;
ustat1= PPBHC|PPDUR4|PPEN|PPDEN;
dm(PPCTL)=ustat1; nop;

idle;

r0=0;
dm(PPCTL)=r0;

r4=2;
r0=1;

//Start the blink routine
top:
r1=1;
r8=0;


lcntr=10000000;
    do (pc,_loop_end) until lce;
_loop_end:
    nop;
r2=r4;

btst r2 by 7;
if not sz r2=bclr r2 by 7;

btst r2 by 0;
if not sz r2=bclr r2 by 0;

r0=pass r0;
if gt jump left;

right:
r2=rot r2 by -1;
jump(pc,2);

left:
r2=rot r2 by 1;

ustat3=r2;
bit tst ustat3 0x2;
if tf r2=bset r2 by 0;
if tf r0=r1;

bit tst ustat3 0x40;
if tf r2=bset r2 by 7;
if tf r0=r8;

r4=r2;

call write_to_flags;

jump top;
_main.end:

write_to_flags:
//The 8 user LEDs on the ADSP-21262 EZ-Kit are mapped to flag
//pins as well as the parallel port AD0-7 pins, so we can use a dma to write the latch to light the LEDs
// new LED value passed in via R4
dm(LED_value)=r4;

// init DMA reg's
r4=LED_value;   dm(IIPP)=r4;
r4=1;           dm(IMPP)=r4;
r4=1;           dm(ICPP)=r4;
r4=1;           dm(EMPP)=r4;

r4=0x01400000;  dm(EIPP)=r4;
r4=1;       dm(ECPP)=r4;
ustat3=     PPTRAN| // transmit in 8-bit mode
            PPBHC|  // bus hold cycle
            PPDUR20; // cycle duration
dm(PPCTL)=ustat3;

// initiate DMA
bit set ustat3 PPDEN|PPEN;
dm(PPCTL)=ustat3;

// wait for DMA to complete
idle;

r4=0;
dm(PPCTL)=r4;

r4=dm(LED_value);   //restore R4
rts;
write_to_flags.end:


⌨️ 快捷键说明

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