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

📄 ezkit push button.asm

📁 ADI 公司的DSP ADSP21369 EZ-KIT LITE开发板的全部源代码
💻 ASM
字号:
 //ADSP-21369 Blink LEDs with the DAI buttons on the EZKIT

//Buttons to push on ezkit:
//IRQ1 blinks LED1&2, IRQ0 blinks LED3&4, DAI_PB19 blinks LED5&6, DAI_PB20 blinks LED7&8.
//DAI_PB19 is associated with interrupt 29 (MISCA1) and Interrupt 29's ISR sets LED5&6.
//DAI_PB20 is associated with interrupt 30 (MISCA2) and Interrupt 30's ISR sets LED7&8.


#include <def21369.h>

// The following definition allows the SRU macro to check for errors. Once the routings have
// been verified, this definition can be removed to save some program memory space.
// The preprocessor will issue a warning stating this when using the SRU macro without this
// definition
#define SRUDEBUG  // Check SRU Routings for errors.
#include <SRU.h>

.global _main;
.global DAIroutine;
.global IRQ0routine;
.global IRQ1routine;

.extern _initPLL;
.extern _initSDRAM;

.section/dm seg_dmda;
.var LED06_value=0;
.var LED07_value=0;

.section/pm seg_pmco;
_main:


call _initPLL;   //Initialize PLL for the correct core clock (CCLK) frequency
call _initSDRAM; //SDRAM is setup for use, but cannot be accessed until MSEN bit is enabled

//Setting the SRU and route so that Flag pins connects to DPI pin buffers.
//Use Flags 4 to 15 only. Flags 0 to 3 not available on the DPI.

    SRU(FLAG6_O,DPI_PB08_I);    // Connect Flag6 output to DPI_PB08 input (LED1)
    SRU(FLAG7_O,DPI_PB13_I);    // Connect Flag7 output to DPI_PB13 input (LED2)
    SRU(FLAG4_O,DPI_PB06_I);    // Connect Flag4 output to DPI_PB06 input (LED3)
    SRU(FLAG5_O,DPI_PB07_I);    // Connect Flag5 output to DPI_PB07 input (LED4)
    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,PBEN15_I);
    SRU(HIGH,PBEN16_I);

// The DAI signals can be routed to the miscellaneous channels (MISCAx) which are
// associated with DAI interrupts, and used as inputs from the Push Buttons.
    ustat3=SRU_EXTMISCA1_INT  | SRU_EXTMISCA2_INT;    //unmask individual interrupts
    dm(DAI_IRPTL_PRI)=ustat3;
    ustat3=SRU_EXTMISCA1_INT  | SRU_EXTMISCA2_INT;    //make sure interrupts latch on the rising edge
    dm(DAI_IRPTL_RE)=ustat3;

//Setting flag pins
    bit set flags FLG3O|FLG4O|FLG5O|FLG6O|FLG7O|FLG8O;

//Clearing flag pins
    bit clr flags FLG3|FLG4|FLG5|FLG6|FLG7|FLG8;

//Set up the IRQ pins to use with the Push Buttons
    ustat3=dm(SYSCTL);
    bit set ustat3 IRQ0EN|IRQ1EN;
    dm(SYSCTL)=ustat3;

    bit set mode2 IRQ0E|IRQ1E;

//Pin Assignments in SRU_PIN3 (Group D)

    //assign pin buffer 19 low so it is an input
    SRU(LOW,DAI_PB19_I);

    //assign pin buffer 20 low so it is an input
    SRU(LOW,DAI_PB20_I);


//Route MISCA signals in SRU_EXT_MISCA (Group E)

    //route so that DAI pin buffer 19 connects to MISCA1
    SRU(DAI_PB19_O,MISCA1_I);

    //route so that DAI pin buffer 20 connects to MISCA2
    SRU(DAI_PB20_O,MISCA2_I);

    //Pin Buffer Disable in SRU_PINEN0 (Group F)
    //assign pin 19 low so it is an input
    SRU(LOW,PBEN19_I);

    //assign pin 20 low so it is an input
    SRU(LOW,PBEN20_I);

//Set up the interrupt hardware
    // Enable Interrupts to handle push buttons
    bit clr irptl IRQ1I|IRQ0I;
    bit set imask IRQ1I|IRQ0I|DAIHI;    //enable IRQ interrupts

    //Set up interrupt priorities
    bit set mode1 IRPTEN;   //enable global interrupts

    ustat3 = SRU_EXTMISCA1_INT  | SRU_EXTMISCA2_INT ;
    dm(DAI_IRPTL_PRI)=ustat3;   //unmask individual interrupts
    dm(DAI_IRPTL_RE)=ustat3;    //make sure interrupts latch on the rising edge


_main.end:  jump(pc,0);


//Set up interrupt service routines to toggle LEDs 1 - 4.
IRQ1routine:

//lights LED1 and LED2 when IRQ1 is asserted
bit tgl flags FLG4;
bit tgl flags FLG5;
rti;
IRQ1routine.end:

IRQ0routine:

//lights LED3 and LED4 when IRQ0 is asserted
bit tgl flags FLG6;
bit tgl flags FLG7;
rti;
IRQ0routine.end:


//Set up DAI routine to toggle LEDs 5 - 8 by calling MISCA1 & MISCA2
DAIroutine:

    //test for SRU_EXTMISCA1_INT
        ustat4=dm(DAI_IRPTL_H);
        bit tst ustat4 SRU_EXTMISCA1_INT;   //SRU_EXTMISCA1_INT represents bit 29
        if TF jump (handle_MISCA1);
    //test for SRU_EXTMISCA2_INT
        bit tst ustat4 SRU_EXTMISCA2_INT;   //SRU_EXTMISCA2_INT represents bit 30
        if TF jump (handle_MISCA2);
rti;
DAIroutine.end:


//Calling MISCA1 to light LED5&6
handle_MISCA1:

    //lights LED5 when DPI_PB14 is asserted
    bit tgl flags FLG8;

    //lights LED6 when DAI_PB15 is asserted
    ustat4=dm(LED06_value);

    //toggle bit in ustat4, store it in memory location of LED06 and test to make sure 0x1 is set in ustat4
    bit tgl ustat4 0x1;
    dm(LED06_value)=ustat4;
    bit tst ustat4 0x1;

    //Test if bit is set
    if TF jump Flag06_Set;

    //if not, go to the "Clear Section" and set it to 1 again
    Flag06_Clear:
        SRU(LOW,DAI_PB15_I);    //light up LED6
        rti;

    Flag06_Set:
        SRU(HIGH,DAI_PB15_I);   //Turn off LED6
        rti;

handle_MISCA1.end:


//Calling MISCA2 to light LED7&8
handle_MISCA2:


    //lights LED8 when MISCA2 is asserted
    bit tgl flags FLG3;

    //lights LED7 when DAI_PB16 is asserted
    ustat4=dm(LED07_value);


    //toggle bit in ustat4, store it in memory location of LED07 and test to make sure 0x1 is set in ustat4
    bit tgl ustat4 0x1;
    dm(LED07_value)=ustat4;
    bit tst ustat4 0x1;

    //Test if bit is set
    if TF jump Flag07_Set;

    //if not, go to the "Clear Section" and set it to 1 again
    Flag07_Clear:
        SRU(LOW,DAI_PB16_I);    //light up LED7
        rti;

    Flag07_Set:
        SRU(HIGH,DAI_PB16_I);   //turn off LED7
        rti;

handle_MISCA2.end:


⌨️ 快捷键说明

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