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

📄 ps2test.lst

📁 ICCAVR下
💻 LST
📖 第 1 页 / 共 2 页
字号:
__text_start:
__start:
    00D4 E5CF      LDI	R28,0x5F
    00D5 E0D4      LDI	R29,4
    00D6 BFCD      OUT	0x3D,R28
    00D7 BFDE      OUT	0x3E,R29
    00D8 51C0      SUBI	R28,0x10
    00D9 40D0      SBCI	R29,0
    00DA EA0A      LDI	R16,0xAA
    00DB 8308      STD	Y+0,R16
    00DC 2400      CLR	R0
    00DD E9E2      LDI	R30,0x92
    00DE E0F0      LDI	R31,0
    00DF E010      LDI	R17,0
    00E0 39E3      CPI	R30,0x93
    00E1 07F1      CPC	R31,R17
    00E2 F011      BEQ	0x00E5
    00E3 9201      ST	R0,Z+
    00E4 CFFB      RJMP	0x00E0
    00E5 8300      STD	Z+0,R16
    00E6 E7E5      LDI	R30,0x75
    00E7 E0F1      LDI	R31,1
    00E8 E6A0      LDI	R26,0x60
    00E9 E0B0      LDI	R27,0
    00EA E011      LDI	R17,1
    00EB 3AE7      CPI	R30,0xA7
    00EC 07F1      CPC	R31,R17
    00ED F021      BEQ	0x00F2
    00EE 95C8      LPM
    00EF 9631      ADIW	R30,1
    00F0 920D      ST	R0,X+
    00F1 CFF9      RJMP	0x00EB
    00F2 940E0176  CALL	_main
_exit:
    00F4 CFFF      RJMP	_exit
FILE: D:\M16开发板实验教程\icc-avr\ps2test\delay.h
(0001) #include<iom16v.h>
(0002) #include <macros.h>
(0003) 
(0004) /*-----------------------------------------------------------*/
(0005) /*-----------------------------------------------------------------------
(0006) 延时函数
(0007) 系统时钟:8M
(0008) -----------------------------------------------------------------------*/
(0009) void delay_1us(void)                 //1us延时函数
(0010)   {
(0011)    asm("nop");
_delay_1us:
    00F5 0000      NOP
    00F6 9508      RET
_delay_nus:
  i                    --> R20
  n                    --> R22
    00F7 940E02A9  CALL	push_gset2
    00F9 01B8      MOVW	R22,R16
(0012)   }
(0013) 
(0014) void delay_nus(unsigned int n)       //N us延时函数
(0015)   {
(0016)    unsigned int i=0;
    00FA 2744      CLR	R20
    00FB 2755      CLR	R21
(0017)    for (i=0;i<n;i++)
    00FC C003      RJMP	0x0100
(0018)    delay_1us();
    00FD DFF7      RCALL	_delay_1us
    00FE 5F4F      SUBI	R20,0xFF
    00FF 4F5F      SBCI	R21,0xFF
    0100 1746      CP	R20,R22
    0101 0757      CPC	R21,R23
    0102 F3D0      BCS	0x00FD
    0103 940E02A0  CALL	pop_gset2
    0105 9508      RET
(0019)   }
(0020)   
(0021) void delay_1ms(void)                 //1ms延时函数
(0022)   {
(0023)    unsigned int i;
(0024)    for (i=0;i<1140;i++);
_delay_1ms:
  i                    --> R16
    0106 2700      CLR	R16
    0107 2711      CLR	R17
    0108 C002      RJMP	0x010B
    0109 5F0F      SUBI	R16,0xFF
    010A 4F1F      SBCI	R17,0xFF
    010B 3704      CPI	R16,0x74
    010C E0E4      LDI	R30,4
    010D 071E      CPC	R17,R30
    010E F3D0      BCS	0x0109
    010F 9508      RET
_delay_nms:
  i                    --> R20
  n                    --> R22
    0110 940E02A9  CALL	push_gset2
    0112 01B8      MOVW	R22,R16
(0025)   }
(0026)   
(0027) void delay_nms(unsigned int n)       //N ms延时函数
(0028)   {
(0029)    unsigned int i=0;
    0113 2744      CLR	R20
    0114 2755      CLR	R21
(0030)    for (i=0;i<n;i++)
    0115 C003      RJMP	0x0119
(0031)    delay_1ms();
    0116 DFEF      RCALL	_delay_1ms
    0117 5F4F      SUBI	R20,0xFF
    0118 4F5F      SBCI	R21,0xFF
    0119 1746      CP	R20,R22
    011A 0757      CPC	R21,R23
    011B F3D0      BCS	0x0116
    011C 940E02A0  CALL	pop_gset2
    011E 9508      RET
_display:
  num                  --> R20
    011F 940E02AB  CALL	push_gset1
    0121 2F40      MOV	R20,R16
FILE: D:\M16开发板实验教程\icc-avr\ps2test\shumaguan.h
(0001) /* 
(0002)    this file is the head file 
(0003) */
(0004) 
(0005) 
(0006) #include<iom16v.h>
(0007) #include<macros.h>
(0008) #include"delay.h"
(0009) //macros.h 中有BIT(x)	(1 << (x))定义,  比如  BIT(5)相当于将第5位置1
(0010) 
(0011) const unsigned char discode[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,
(0012)                                0x82,0xf8,0x80,0x90,0x88,0x83,
(0013) 							   0xc6,0xa1,0x86,0x8e,0xbf}; //共阳数码管
(0014) 
(0015) /*------------------------------------------------------------------
(0016) fuction: display in hex formart
(0017) para   : hi--the high two bits to be displayed
(0018)          low--the low two bits to be displayed
(0019) -------------------------------------------------------------------*/
(0020) void display(unsigned char num)
(0021) {
(0022)      PORTB &=~BIT(PORTB0);           //light the first bit of the shumaguan
    0122 98C0      CBI	0x18,0
(0023) 	                                 //PORTB0 was defined in iom16v.h
(0024)  	 PORTA=discode[num>>4];               //display the thousand bit    
    0123 E684      LDI	R24,0x64
    0124 E091      LDI	R25,1
    0125 2FE4      MOV	R30,R20
    0126 27FF      CLR	R31
    0127 95F5      ASR	R31
    0128 95E7      ROR	R30
    0129 95F5      ASR	R31
    012A 95E7      ROR	R30
    012B 95F5      ASR	R31
    012C 95E7      ROR	R30
    012D 95F5      ASR	R31
    012E 95E7      ROR	R30
    012F 0FE8      ADD	R30,R24
    0130 1FF9      ADC	R31,R25
    0131 91E4      LPM	R30,0(Z)
    0132 BBEB      OUT	0x1B,R30
(0025) 	 delay_nms(5);                           
    0133 E005      LDI	R16,5
    0134 E010      LDI	R17,0
    0135 DFDA      RCALL	_delay_nms
(0026) 	 PORTB |=BIT(PORTB0);             //turn off the first bit of the shumaguan
    0136 9AC0      SBI	0x18,0
(0027)  	 
(0028) 	 PORTB &=~BIT(PORTB1);
    0137 98C1      CBI	0x18,1
(0029)  	 PORTA=discode[num%16];
    0138 E120      LDI	R18,0x10
    0139 E030      LDI	R19,0
    013A 2F04      MOV	R16,R20
    013B 2711      CLR	R17
    013C 940E0266  CALL	mod16s
    013E 01F8      MOVW	R30,R16
    013F E684      LDI	R24,0x64
    0140 E091      LDI	R25,1
    0141 0FE8      ADD	R30,R24
    0142 1FF9      ADC	R31,R25
    0143 91E4      LPM	R30,0(Z)
    0144 BBEB      OUT	0x1B,R30
(0030) 	 delay_nms(5);
    0145 E005      LDI	R16,5
    0146 E010      LDI	R17,0
    0147 DFC8      RCALL	_delay_nms
(0031) 	 PORTB |=BIT(PORTB1);
    0148 9AC1      SBI	0x18,1
    0149 940E02AE  CALL	pop_gset1
    014B 9508      RET
(0032) 	
(0033) }
(0034) /*---------------------------------------------------------------------
(0035) fuction: display error,this will display "- - - -" on the four bits leds
(0036) ----------------------------------------------------------------------*/
(0037) void displayerror(void)
(0038) {
(0039) 	 PORTB &=~1;           //light the first bit of the shumaguan
_displayerror:
    014C 98C0      CBI	0x18,0
(0040) 	                                 //PORTB0 was defined in iom16v.h
(0041)  	 PORTA=discode[16];               //display the thousand bit    
    014D E7E4      LDI	R30,0x74
    014E E0F1      LDI	R31,1
    014F 91E4      LPM	R30,0(Z)
    0150 BBEB      OUT	0x1B,R30
(0042) 	 delay_nms(5);                          
    0151 E005      LDI	R16,5
    0152 E010      LDI	R17,0
    0153 DFBC      RCALL	_delay_nms
(0043) 	 PORTB |=1;             //turn off the first bit of the shumaguan
    0154 9AC0      SBI	0x18,0
(0044)  	 
(0045) 	 PORTB &=~2;
    0155 98C1      CBI	0x18,1
(0046)  	 PORTA=discode[16];
    0156 E7E4      LDI	R30,0x74
    0157 E0F1      LDI	R31,1
    0158 91E4      LPM	R30,0(Z)
    0159 BBEB      OUT	0x1B,R30
(0047) 	 delay_nms(5);   
    015A E005      LDI	R16,5
    015B E010      LDI	R17,0
    015C DFB3      RCALL	_delay_nms
(0048) 	 PORTB |=2;
    015D 9AC1      SBI	0x18,1
    015E 9508      RET
FILE: D:\M16开发板实验教程\icc-avr\ps2test\ps2test.c
(0001) /* 
(0002)     Title:    icc-avr ps2 test
(0003)     Author:   dushibiao
(0004)     Date:     2007 10 18
(0005)     Purpose:  decode ps2 keyboard code
(0006) 	Frequency: internal 8M
(0007)     Software: icc-avr 
(0008)     Hardware: AVR mega16 BOARD
(0009)     Connect:  dushibiao@126.com
(0010) */
(0011) 
(0012) #include <iom16v.h>
(0013) #include "scancodes.h"
(0014) #include "shumaguan.h"
(0015) 
(0016) #define PORT_KB PORTD
(0017) #define PIN_KB PIND
(0018) #define PIN_DIR DDRD
(0019) #define CLOCK 3
(0020) #define DATAPIN 2
(0021) 
(0022) //管脚定义
(0023) #define PIN_RXD			0 	//PD0   RXD
(0024) #define PIN_TXD			1 	//PD1   TXD
(0025) 
(0026) //常量定义
(0027) #define BAUDRATE        9600	//baudrate
(0028) #define F_CPU			8000000 //the frequency of the global clock
(0029) 
(0030) 
(0031) unsigned char bitcount; 
(0032) 
(0033) volatile unsigned char origialcode=0;
(0034) 
(0035) void intinitial(void);
(0036) void portinitial(void); //initialize ports
(0037) void init_USART(void);
(0038) unsigned char decode(unsigned char sc);
(0039) 
(0040) /*-----------------------------------------------------------------
(0041) function: send a char to the uart
(0042) para:    the char to be send
(0043) -----------------------------------------------------------------*/
(0044) void put_c(unsigned char c) //发送采用查询方式
(0045) {
(0046) 	while( !(UCSRA & (1<<UDRE)) );        //wait until the uart is empty
_put_c:
  c                    --> R16
    015F 9B5D      SBIS	0x0B,5
    0160 CFFE      RJMP	_put_c
(0047) 	UDR=c;                                  //write data to uart
    0161 B90C      OUT	0x0C,R16
    0162 9508      RET
_put_s:
  ptr                  --> R20
    0163 940E02AB  CALL	push_gset1
    0165 01A8      MOVW	R20,R16
(0048) }
(0049) /*-----------------------------------------------------------------
(0050) function: send a string to the uart
(0051) para:     ptr---the pointer point to the string
(0052) ------------------------------------------------------------------*/
(0053) void put_s(unsigned char *ptr)
(0054) {
    0166 C004      RJMP	0x016B
(0055) 	while (*ptr)
(0056) 	{
(0057) 		put_c(*ptr++);
    0167 01FA      MOVW	R30,R20
    0168 9101      LD	R16,Z+
    0169 01AF      MOVW	R20,R30
    016A DFF4      RCALL	_put_c
    016B 01FA      MOVW	R30,R20
    016C 8020      LDD	R2,Z+0
    016D 2022      TST	R2
    016E F7C1      BNE	0x0167
(0058) 	}
(0059) 	put_c(0x0D); 
    016F E00D      LDI	R16,0xD
    0170 DFEE      RCALL	_put_c
(0060) 	put_c(0x0A);  //结尾发送回车换行
    0171 E00A      LDI	R16,0xA
    0172 DFEC      RCALL	_put_c
    0173 940E02AE  CALL	pop_gset1
    0175 9508      RET
(0061) }
(0062) 
(0063) void  main(void)
(0064) {
(0065)       portinitial();
_main:
    0176 D016      RCALL	_portinitial
(0066)  	  intinitial();
    0177 D01F      RCALL	_intinitial
(0067) 	  init_USART();
    0178 D051      RCALL	_init_USART
(0068) 	  
(0069) 
(0070)       put_s("PS2--KEYOARD test");
    0179 E800      LDI	R16,0x80
    017A E010      LDI	R17,0
    017B DFE7      RCALL	_put_s
(0071)       put_s("dushibiao");
    017C E706      LDI	R16,0x76
    017D E010      LDI	R17,0
    017E DFE4      RCALL	_put_s
(0072)       put_s("dushibiao@126.com");
    017F E604      LDI	R16,0x64
    0180 E010      LDI	R17,0
    0181 DFE1      RCALL	_put_s
(0073)       put_c(0x0a);
    0182 E00A      LDI	R16,0xA
    0183 DFDB      RCALL	_put_c
(0074)       put_c(0x0d);//换行 
    0184 E00D      LDI	R16,0xD
    0185 DFD9      RCALL	_put_c
(0075) 
(0076) 	  SEI();            //enable interrupt ,this was predefined in MACROS.h
    0186 9478      BSET	7
    0187 C003      RJMP	0x018B
(0077) 	 
(0078) 	while(1)
(0079)     {
(0080) 		display(origialcode);
    0188 91000060  LDS	R16,origialcode
    018A DF94      RCALL	_display
    018B CFFC      RJMP	0x0188
    018C 9508      RET
(0081) 	}
(0082) 	  
(0083) }
(0084) /*********************************************************************
(0085) fuction: ports initialize
(0086) **********************************************************************/
(0087) void portinitial(void)
(0088) {
(0089)  	 PORTA=0XFF;
_portinitial:
    018D EF8F      LDI	R24,0xFF
    018E BB8B      OUT	0x1B,R24
(0090)      DDRA=0XFF;                  //OUT
    018F BB8A      OUT	0x1A,R24
(0091) 	 PORTB=0XFF;
    0190 BB88      OUT	0x18,R24
(0092) 	 DDRB=0X0F;                  //high fout bit in , low four bits out
    0191 E08F      LDI	R24,0xF
    0192 BB87      OUT	0x17,R24
(0093) 	 PORTC=0XFF;                 //pull up
    0193 EF8F      LDI	R24,0xFF
    0194 BB85      OUT	0x15,R24
(0094) 	 PORTD=0XFF;                 //pull up
    0195 BB82      OUT	0x12,R24
    0196 9508      RET
(0095) }
(0096) 
(0097) /*********************************************************************
(0098) fuction: ext interrupt initialize
(0099) **********************************************************************/
(0100) void intinitial(void)      //int1 ,int0下降沿中断
(0101) {
(0102)  	 MCUCR=(1<<ISC10);            //falling edge interrup
_intinitial:
    0197 E084      LDI	R24,4
    0198 BF85      OUT	0x35,R24
(0103) 	 GICR |=(1<<INT1);             //enable ext0,ext1 interrupt
    0199 B78B      IN	R24,0x3B
    019A 6880      ORI	R24,0x80
    019B BF8B      OUT	0x3B,R24
(0104) 	 bitcount = 11;
    019C E08B      LDI	R24,0xB
    019D 93800092  STS	bitcount,R24
    019F 9508      RET
_int1pro:
  code                 --> R20
  i                    --> R22
    01A0 940E02C2  CALL	push_lset
    01A2 940E02A9  CALL	push_gset2
(0105) }
(0106) 
(0107) /*********************************************************************
(0108) fuction: ext1 interrupt  service routine
(0109) **********************************************************************/
(0110) #pragma interrupt_handler int1pro: iv_INT1
(0111) void int1pro(void)
(0112) {
(0113)  	 unsigned char i,code;
(0114)      	if ((PIN_KB&(1<<DATAPIN))==0)
    01A4 9982      SBIC	0x10,2
    01A5 C01F      RJMP	0x01C5
(0115) 		{
(0116) 		   while((PIN_KB&(1<<CLOCK))==0);
    01A6 9B83      SBIS	0x10,3
    01A7 CFFE      RJMP	0x01A6
(0117) 		   for(i=0;i<8;i++)
    01A8 2766      CLR	R22
    01A9 C009      RJMP	0x01B3
(0118) 		   {
(0119) 		      while(PIN_KB&(1<<CLOCK));
    01AA 9983      SBIC	0x10,3
    01AB CFFE      RJMP	0x01AA
(0120) 		      code>>=1;

⌨️ 快捷键说明

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