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

📄 dsp.txt

📁 利用达盛DSP试验箱设计键盘输入发生装置
💻 TXT
字号:
extern void InitC5402(void);
extern void InitMcBSP0(void);
extern void ms_delay(int);
extern void send_0(void);
extern void send_1(void);
extern void send_2(void);
extern void send_end(void);
extern void INT3_ISR(void);
extern void porta();
extern void portb();
void write7279(unsigned int cmd,unsigned int dta);
void long_delay(void);
void short_delay(void);
interrupt void key_int();
** Main Function Program
#define DECODE0 0x80
#define CMD_READ 0x15
unsigned int byteout,key_a=2;
char a,b;
void main(void)
{	InitC5402();  
	InitMcBSP0();
	ms_delay(100);
     while(1)
      {ms_delay(100*key_a);
	          porta();
		 ms_delay(100*key_a);
			  portb();
      }
}
void write7279(unsigned int cmd,unsigned int dta)
{   unsigned char i;
	unsigned int cmddata;
    asm(" NOP ");
    asm(" NOP ");
    asm(" NOP ");
	dta=(dta&0x00ff);
    asm(" NOP ");
    asm(" NOP ");
    asm(" NOP ");
	cmddata=((cmd<<8)|dta);
	asm(" NOP ");
    asm(" NOP ");
    asm(" NOP ");
	send_0();
for (i=0;i<16;i++)
{   if(cmddata&0x8000)
	{send_1();
	}
	else 
	{send_2();
	}
	cmddata=cmddata*2;
}
send_end();
}
void long_delay(void)
{   unsigned char i,j;
	for (i=0;i<0xfff;i++)
	{   for(j=0;j<0x50;j++)
		{}
	}
}
void short_delay(void)
{    unsigned char i,j;
	for(i=0;i<0x10;i++)
	{  for(j=0;j<0x100;j++)
	{}
	}
}
interrupt void key_int()
{   asm(" NOP ");
    INT3_ISR();
	asm(" NOP ");
	asm(" NOP ");
	asm(" NOP ");
    key_a=*(unsigned *)0x15;
	asm(" NOP ");
	asm(" NOP ");
	asm(" NOP ");
	write7279(DECODE0,key_a);
	if(key_a==0xf)
	{   main();
	}
}
	INT3_ISR程序清单
    ;.mmregs
	.include MMRegs.h
	.global _INT3_ISR ,write_7279 
	.ref  us_delay ,_ms_delay 
	;.bss 	_key_code_vlue,1,0,0
_INT3_ISR:
       ;CS<=DX, C_KEY_7279<=FSR, CLK<=CLKX, DATA<=CLKR(CLKR<=DATA)
     LD     #0, DP               ; reset data-page pointer
            
     STM   #0x2900,ST1           ; ST1 at default (note:INTX=1
******* Disable All Interrupts *******
     SSBX  INTM                  ; disable (mask) global(CPU) intrpts 
     STM   #0x0000, IMR          ; disable peripheral interrupts
     STM   #0xFFFF, IFR          ; clear the intrupts' flags
     STM #0,AR6 
     STM   PCR, McBSP0_SPSA	  
     STM   #3F24h, McBSP0_SPSD    ; 1x x100     
     NOP
     NOP
     STM   #3F04h, McBSP0_SPSD   ;  0x x100
     NOP                          ; delay  45us
     stm #45,ar3
	 call us_delay
	 								;  0x15 + data
     STM   #3F06h, McBSP0_SPSD    ;0x x110  
     stm #18,ar3
	 call us_delay
     STM   #3F04h, McBSP0_SPSD    ;0x x100     1 
     stm #20,ar3
	 call us_delay
     STM   #3F06h, McBSP0_SPSD    ;0x x110 
     stm #18,ar3
	 call us_delay
     STM   #3F04h, McBSP0_SPSD    ;0x x100     2 
     stm #20,ar3
	 call us_delay
     STM   #3F06h, McBSP0_SPSD    ;0x x110  
     stm #18,ar3
	 call us_delay
     STM   #3F04h, McBSP0_SPSD    ;0x x100     3 
     stm #20,ar3
	 call us_delay
     STM   #3F07h, McBSP0_SPSD    ;0x x111  
     stm #18,ar3
	 call us_delay
     STM   #3F05h, McBSP0_SPSD    ;0x x101     4 
     stm #20,ar3
	 call us_delay
     STM   #3F06h, McBSP0_SPSD    ;0x x110  
     stm #18,ar3
	 call us_delay
     STM   #3F04h, McBSP0_SPSD    ;0x x100     5 
     stm #20,ar3
	 call us_delay
     STM   #3F07h, McBSP0_SPSD    ;0x x111  
     stm #18,ar3
	 call us_delay
     STM   #3F05h, McBSP0_SPSD    ;0x x101     6 
     stm #20,ar3
	 call us_delay 
     STM   #3F06h, McBSP0_SPSD    ;0x x110  
     stm #18,ar3
	 call us_delay
     STM   #3F04h, McBSP0_SPSD    ;0x x100     7 
     stm #20,ar3
	 call us_delay
     STM   #3F07h, McBSP0_SPSD    ;0x x111  
     stm #18,ar3
	 call us_delay
     STM   #3F05h, McBSP0_SPSD    ;0x x101     8 
     stm #20,ar3
	 call us_delay
     STM   #3F04h, McBSP0_SPSD    ;0x x100 
     stm #8,ar3
	 call us_delay
     STM   #3F05h, McBSP0_SPSD    ;0x x101       
          ;CS<=DX,      C_KEY_7279<=FSR,   CLK<=CLKX,  DATA<=CLKR(CLKR<=DATA)
     nop
     nop
     stm #80,ar3
	 call us_delay
     nop
     STM   #3F03h, McBSP0_SPSD    ;0x x011 
     stm #5,ar3
	 call us_delay 
     STM   #3E02h, McBSP0_SPSD    ;0x x01x 
     stm #20,ar3
	 call us_delay 
     LDM McBSP0_SPSD,A
     AND  #0001h,A 
     SFTL A,+7  
     STL A,AR6                         
     STM   #3E00h, McBSP0_SPSD    ;0x x00x 		9
     stm #18,ar3
	 call us_delay
     STM   #3E02h, McBSP0_SPSD    ;0x x01x
     stm #20,ar3
	 call us_delay  
     PSHM B 
     LD #0,B
     LDM McBSP0_SPSD,A
     AND  #0001h,A   
     SFTL A,+6,B
     LDM AR6,A
     OR B,A 
     STL A,AR6 
     POPM B
     STM   #3E00h, McBSP0_SPSD    ;0x x00x 		10
     stm #18,ar3
	 call us_delay
     STM   #3E02h, McBSP0_SPSD    ;0x x01x 
     stm #20,ar3
	 call us_delay 
     PSHM B 
     LD #0,B
     LDM McBSP0_SPSD,A
     AND  #0001h,A   
     SFTL A,+5,B
     LDM AR6,A
     OR B,A 
     STL A,AR6 
     POPM B
     STM   #3E00h, McBSP0_SPSD    ;0x x00x 		11
     stm #18,ar3
	 call us_delay
     STM   #3E02h, McBSP0_SPSD    ;0x x01x 
     stm #20,ar3
	 call us_delay 
     PSHM B 
     LD #0,B
     LDM McBSP0_SPSD,A
     AND  #0001h,A   
     SFTL A,+4,B
     LDM AR6,A
     OR B,A 
     STL A,AR6 
     POPM B
     STM   #3E00h, McBSP0_SPSD    ;0x x00x 		12
     stm #18,ar3
	 call us_delay
     STM   #3E02h, McBSP0_SPSD    ;0x x01x 
     stm #20,ar3
	 call us_delay 
     PSHM B 
     LD #0,B
     LDM McBSP0_SPSD,A
     AND  #0001h,A   
     SFTL A,+3,B
     LDM AR6,A
     OR B,A 
     STL A,AR6 
     POPM B
     STM   #3E00h, McBSP0_SPSD    ;0x x00x 		13
     
     stm #18,ar3
	 call us_delay
     STM   #3E02h, McBSP0_SPSD    ;0x x01x 
     stm #20,ar3
	 call us_delay 
     PSHM B 
     LD #0,B
     LDM McBSP0_SPSD,A
     AND  #0001h,A   
     SFTL A,+2,B
     LDM AR6,A
     OR B,A 
     STL A,AR6 
     POPM B 
     STM   #3E00h, McBSP0_SPSD    ;0x x00x 		14
     stm #18,ar3
	 call us_delay
     STM   #3E02h, McBSP0_SPSD    ;0x x01x 
     stm #20,ar3
	 call us_delay 
     PSHM B 
     LD #0,B
     LDM McBSP0_SPSD,A
     AND  #0001h,A   
     SFTL A,+1,B
     LDM AR6,A
     OR B,A 
     STL A,AR6 
     POPM B
     STM   #3E00h, McBSP0_SPSD    ;0x x00x 		15
     stm #18,ar3
	 call us_delay
     STM   #3E02h, McBSP0_SPSD    ;0x x01x 
     stm #20,ar3
	 call us_delay 
     PSHM B 
     LD #0,B
     LDM McBSP0_SPSD,A
     AND  #0001h,A   
     SFTL A,+0,B
     LDM AR6,A
     OR B,A 
     STL A,AR5 
     POPM B
     STM   #3F04h, McBSP0_SPSD    ;0x x100 		16
     stm #40,ar3
	 call us_delay 
	 STM   #3F24h, McBSP0_SPSD    ;1x x110 		
     NOP
    nop
	nop      
    STM   #0x6900,ST1           ; ST1 at default (note:INTX=1
    STM   #0FFFFH,IFR
    STM   #0x0101, IMR          ; able MCBSP0 RX TX INTERRUPT
    RSBX  INTM                  ; able (mask) global(CPU) intrpts 
	NOP
	NOP
    NOP
    RET
port程序清单
.mmregs
	.global	_porta
	.global	_portb
_porta:     ;向I/O口8001H发送数据5555H
	stm		304h,ar1 
	st		0000h,*ar1
	portw	*ar1,8001h
	ret
_portb:     ;向I/O口8001H发送数据AAAAH
	stm		304h,ar1
	st		0ffffh,*ar1
	portw	*ar1,8001h
	ret

⌨️ 快捷键说明

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