📄 ezkit push button.asm
字号:
//ADSP-21262 Blink LEDs with the DAI buttons on the EZKIT
//Buttons to push on ezkit: DAI_P19 blinks LED1, DAI_P20 blinks LED2
//DAI_P19 is associated with interrupt 23 (MISCB1) and Interrupt 23's ISR sets LED1
//DAI_P20 is associated with interrupt 24 (MISCB2) and Interrupt 24's ISR sets LED2
#include <def21262.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 IRQ1routine;
.global IRQ2routine;
//LED Positions
#define IRQ1LED 1<<24
#define IRQ2LED 2<<24
#define DAIPIN19LED 4<<24
#define DAIPIN20LED 8<<24
.section/dm seg_dmda;
.var LED_value=0;
.section/pm seg_pmco;
_main:
//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 the parallel port
//to write the latch to light the LEDs
ustat3=0x1400000; dm(EIPP)=ustat3;
ustat3=1; dm(ECPP)=ustat3;
ustat3=0; dm(EMPP)=ustat3;
ustat3= PPTRAN| // transmit in 8-bit mode
PPBHC| // bus hold cycle
PPDUR20| // cycle duration
PPEN; // Enable for core driven transfer.
dm(PPCTL)=ustat3;
ustat3=SRU_EXTMISCB1_INT | SRU_EXTMISCB2_INT; //unmask individual interrupts
dm(DAI_IRPTL_PRI)=ustat3;
ustat3=SRU_EXTMISCB1_INT | SRU_EXTMISCB2_INT; //make sure interrupts latch on the rising edge
dm(DAI_IRPTL_RE)=ustat3;
//Set up interrupt priorities
bit set mode1 IRPTEN; //enable global interrupts
bit set imask DAIHI; //make DAI interrupts high priority
ustat3 = SRU_EXTMISCB1_INT | SRU_EXTMISCB2_INT ;
dm(DAI_IRPTL_PRI)=ustat3; //unmask individual interrupts
dm(DAI_IRPTL_RE)=ustat3; //make sure interrupts latch on the rising edge
ustat3=dm(SYSCTL);
bit set ustat3 IRQ1EN|IRQ2EN;
dm(SYSCTL)=ustat3;
bit set mode2 IRQ1E|IRQ2E;
//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 MISCB singnals in SRU_EXT_MISCB (Group E)
//route so that DAI pin buffer 19 connects to MISCB1
SRU(DAI_PB19_O,MISCB1_I);
//route so that DAI pin buffer 20 connects to MISCB2
SRU(DAI_PB20_O,MISCB2_I);
//Pin Buffer Disable in SRU_PINEN0 (Group F)
//assign pin 19 low so it is an input
SRU(LOW,DAI_PB19_I);
//assign pin 20 low so it is an input
SRU(LOW,DAI_PB20_I);
bit clr irptl IRQ2I|IRQ1I;
bit set imask IRQ2I|IRQ1I; //enable IRQ interrupts
jump(pc,0);
_main.end:
//Set up interrupt service routines to toggle LEDs 1 - 4.
IRQ1routine:
//lights LED1 when IRQ1 is asserted
ustat4=dm(LED_value);
bit tgl ustat4 IRQ1LED;
dm(TXPP)=ustat4;
dm(LED_value)=ustat4;
rti;
IRQ1routine.end:
IRQ2routine:
//lights LED1 when IRQ2 is asserted
ustat4=dm(LED_value);
bit tgl ustat4 IRQ2LED;
dm(TXPP)=ustat4;
dm(LED_value)=ustat4;
rti;
IRQ2routine.end:
DAIroutine:
//test for SRU_EXTMISCB1_INT
r0=dm(DAI_IRPTL_H);
btst r0 by 23;
if not sz call (handle_MISCB1);
//test for SRU_EXTMISCB2_INT
btst r0 by 24;
if not sz call (handle_MISCB2);
rti;
DAIroutine.end:
handle_MISCB1:
//lights LED3 when DAI_P19 is asserted
ustat4=dm(LED_value);
bit tgl ustat4 DAIPIN19LED;
dm(TXPP)=ustat4;
dm(LED_value)=ustat4;
rts;
handle_MISCB1.end:
handle_MISCB2:
//lights LED4 when DAI_P20 is asserted
ustat4=dm(LED_value);
bit tgl ustat4 DAIPIN20LED;
dm(TXPP)=ustat4;
dm(LED_value)=ustat4;
rts;
handle_MISCB2.end:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -