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

📄 main.s

📁 超简单的编码开关(单键飞梭开关)解码程序
💻 S
📖 第 1 页 / 共 5 页
字号:
	.byte 161,243
	.byte 1,0
	.byte 2,128
	.byte 4,64
	.byte 8,32
	.byte 16,16
	.byte 32,8
	.byte 64,4
	.byte 128,2
	.byte 64,4
	.byte 32,8
	.byte 16,16
	.byte 8,32
	.byte 4,64
	.byte 2,128
	.byte 1,0
	.byte 0,0
	.byte 161,245
	.byte 0,0
	.byte 127,252
	.byte 64,4
	.byte 64,4
	.byte 64,4
	.byte 64,4
	.byte 64,4
	.byte 64,4
	.byte 64,4
	.byte 64,4
	.byte 64,4
	.byte 64,4
	.byte 64,4
	.byte 127,252
	.byte 0,0
	.byte 0,0
	.byte 161,238
	.byte 1,0
	.byte 1,0
	.byte 2,128
	.byte 2,128
	.byte 2,128
	.byte 4,64
	.byte 252,126
	.byte 64,4
	.byte 48,24
	.byte 8,32
	.byte 8,32
	.byte 17,144
	.byte 22,'P
	.byte 24,48
	.byte 32,8
	.byte 0,0
	.byte 161,230
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 's,192
	.byte 'T,48
	.byte 'x,16
	.byte 8,16
	.byte 8,0
	.byte 8,0
	.byte 8,0
	.byte 8,0
	.byte 8,16
	.byte 4,32
	.byte 3,192
	.byte 0,0
	.byte 212,246
	.byte 34,8
	.byte 33,140
	.byte 32,144
	.byte 35,254
	.byte 250,34
	.byte 34,170
	.byte 34,'r
	.byte 35,254
	.byte 32,0
	.byte 33,252
	.byte 57,4
	.byte 225,252
	.byte 'A,4
	.byte 1,4
	.byte 1,252
	.byte 1,4
	.byte 188,211
	.byte 8,0
	.byte 8,0
	.byte 8,0
	.byte 127,124
	.byte 9,'D
	.byte 9,'D
	.byte 9,'D
	.byte 9,'D
	.byte 17,'D
	.byte 17,'D
	.byte 17,'D
	.byte 33,'D
	.byte 33,124
	.byte 'E,'D
	.byte 130,64
	.byte 0,0
	.byte 188,245
	.byte 0,32
	.byte 64,40
	.byte 32,36
	.byte 47,254
	.byte 8,32
	.byte 47,228
	.byte 40,38
	.byte 40,44
	.byte 'K,168
	.byte 202,168
	.byte 'J,144
	.byte 'S,146
	.byte 'R,170
	.byte 32,'F
	.byte 'A,130
	.byte 0,0
	.byte 201,217
	.byte 1,0
	.byte 1,0
	.byte 1,32
	.byte 9,16
	.byte 13,12
	.byte 9,8
	.byte 17,0
	.byte 33,8
	.byte 'A,12
	.byte 1,24
	.byte 0,48
	.byte 0,96
	.byte 1,128
	.byte 14,0
	.byte 'p,0
	.byte 0,0
	.dbstruct 0 34 typFNT_GB16
	.dbfield 0 Index A[2:2]c
	.dbfield 2 Msk A[32:32]c
	.dbend
	.dbsym e GB_16 _GB_16 A[340:10]kS[typFNT_GB16]
	.area data(ram, con, rel)
	.dbfile F:\bss\AVR-ICC\qingxi/ZM.H
_OperPowerCode::
	.blkw 1
	.area idata
	.word L2
	.area data(ram, con, rel)
	.dbfile F:\bss\AVR-ICC\qingxi/ZM.H
	.blkw 1
	.area idata
	.word L3
	.area data(ram, con, rel)
	.dbfile F:\bss\AVR-ICC\qingxi/ZM.H
	.blkw 1
	.area idata
	.word L4
	.area data(ram, con, rel)
	.dbfile F:\bss\AVR-ICC\qingxi/ZM.H
	.blkw 1
	.area idata
	.word L5
	.area data(ram, con, rel)
	.dbfile F:\bss\AVR-ICC\qingxi/ZM.H
	.dbfile F:\bss\AVR-ICC\qingxi\main.c
	.dbsym e OperPowerCode _OperPowerCode A[8:4]pkc
	.area text(rom, con, rel)
	.dbfile F:\bss\AVR-ICC\qingxi\main.c
	.dbfunc e delay_us _delay_us fV
;             us -> R16,R17
	.even
_delay_us::
	.dbline -1
	.dbline 158
; //ICC-AVR application builder : 2005-10-22 20:39:47
; // Target : M32  ,Fuse: 0xAF,0xD4   BLB11:0 BLB12:0
; // Crystal:  8.000000Mhz
; // LCD: 北京青云LCM2401281 (T6963驱动),模拟时序驱动
; // 注意:0x7C00-0x7fff 保留为bootloader区  (512Word)
; 
; #include <iom32v.h>
; #include <macros.h>
; #include <eeprom.h>
; #include "stdarg.h"
; #include "stdio.h"
; 
; //英文及中文字模图标
; #include "ZM.H"      
; 
; #define uchar           unsigned char 
; #define uint            unsigned int
; #define cchar           const unsigned char
; 
; #ifndef 	StructRowandcol
; 	struct	rowandcol
; 	{
; 		uchar row;
; 		uchar col;
; 	};
; 	#define 	StructRowandcol
; #endif
; 
; #ifndef 	UnionAddress
; 	union 	address 
; 	{
; 		uint a;
; 		struct
; 		{
; 			uchar ah;
; 			uchar al;
; 		}apart;
; 	};
; 	#define 	UnionAddress
; #endif
; 
; 
; union uint2uchars
; {
; 	uint uintx;
; 	uchar ucharx[2];
; };
; 
; 
; //LCD Size
; 
; #define LCD_LEFT        0
; #define LCD_TOP         0
; #define LCD_RIGHT       239
; #define LCD_BOTTOM      127
; 
; #define LCD_DELAY       0
; 
; //LCD功能引脚定义
; #define LCD_RW          PD7
; #define LCD_RD          PD4
; #define LCD_CE          PD5
; #define LCD_CD          PD3
; #define LCD_RES         PD6
; #define LCD_CODE_P      PORTD
; 
; 
; #define LCD_RW_H        LCD_CODE_P |=  BIT(LCD_RW)
; #define LCD_RW_L        LCD_CODE_P &= ~BIT(LCD_RW)
; #define LCD_RD_H        LCD_CODE_P |=  BIT(LCD_RD)
; #define LCD_RD_L        LCD_CODE_P &= ~BIT(LCD_RD)
; #define LCD_CE_H        LCD_CODE_P |=  BIT(LCD_CE)
; #define LCD_CE_L        LCD_CODE_P &= ~BIT(LCD_CE)
; #define LCD_CD_H        LCD_CODE_P |=  BIT(LCD_CD)
; #define LCD_CD_L        LCD_CODE_P &= ~BIT(LCD_CD)
; #define LCD_RES_H       LCD_CODE_P |=  BIT(LCD_RES)
; #define LCD_RES_L       LCD_CODE_P &= ~BIT(LCD_RES)
; 
; #define LCD_DATA        PINC
; #define LCD_DDR         DDRC
; #define LCD_PORT        PORTC
; /***********************************************************************************/
; 
; // ASCII 字模宽度及高度定义
; #define 		ASC_CHR_WIDTH		 8
; #define 		ASC_CHR_HEIGHT		12
; 
; //定义ASCII码
; #define		STX			0x02
; #define		ETX			0x03
; #define		EOT			0x04
; #define		ENQ			0x05
; #define		BS				0x08
; #define		CR				0x0D
; #define		LF				0x0A
; #define		DLE			0x10
; #define		ETB			0x17
; #define		SPACE			0x20
; #define		COMMA			0x2C
; 
; // T6963C 命令定义
; #define 	LC_CUR_POS		0x21		// 光标位置设置
; #define 	LC_CGR_POS		0x22		// CGRAM偏置地址设置
; #define 	LC_ADD_POS		0x24		// 地址指针位置
; #define 	LC_TXT_STP		0x40		// 文本区首址
; #define 	LC_TXT_WID		0x41		// 文本区宽度
; #define 	LC_GRH_STP		0x42		// 图形区首址
; #define 	LC_GRH_WID		0x43		// 图形区宽度
; #define 	LC_MOD_OR		0x80		// 显示方式:逻辑“或”
; #define 	LC_MOD_XOR		0x81		// 显示方式:逻辑“异或”
; #define 	LC_MOD_AND		0x82		// 显示方式:逻辑“与”
; #define 	LC_MOD_TCH		0x83		// 显示方式:文本特征
; #define 	LC_DIS_SW		0x90		// 显示开关:D0=1/0:光标闪烁启用/禁用;
; 											// 			 D1=1/0:光标显示启用/禁用;
; 											// 			 D2=1/0:文本显示启用/禁用;
; 											// 			 D3=1/0:图形显示启用/禁用;
; #define 	LC_CUR_SHP		0xA1		// 光标形状选择:0xA0-0xA7表示光标占的行数
; #define 	LC_AUT_WR		0xB0		// 自动写设置
; #define 	LC_AUT_RD		0xB1		// 自动读设置
; #define 	LC_AUT_OVR		0xB2		// 自动读/写结束
; #define 	LC_INC_WR		0xC0		// 数据一次写,地址加1
; #define 	LC_INC_RD		0xC1		// 数据一次读,地址加1
; #define 	LC_DEC_WR		0xC2		// 数据一次写,地址减1
; #define 	LC_DEC_RD		0xC3		// 数据一次读,地址减1
; #define 	LC_NOC_WR		0xC4		// 数据一次写,地址不变
; #define 	LC_NOC_RD		0xC5		// 数据一次读,地址不变
; #define 	LC_SCN_RD		0xE0		// 屏读
; #define 	LC_SCN_CP		0xE8		// 屏拷贝
; #define 	LC_BIT_OP		0xF0		// 位操作:D0-D2:定义D0-D7位;D3:1置位;0:清除
; 
; 
; const uchar *OperPowerCode[4]={"低  ","中  ","高  ","超高"};    
; #define CompanyName  "江苏镇江爱邦电子科技有限公司" 
; 
; //定义全局变量
; uchar Freq_H,keycounter,keydirection;    //Freq频率,KEY键值,key-direct
; uchar mSEC,UpdateFlag,S_flag;  
; uint  Freq,lastfreq;
; uchar DisplayBuffer[7];				  //显示数据缓冲
; uchar gCurRow,gCurCol;	    // 当前行、列存储,行高16点,列宽8点
; 
; //蜂鸣器接PortB.1
; #define beep (1<<1)                        
; #define beep_1() (PORTB |=beep)
; #define beep_0() (PORTB &=~beep)
; #define beep_off() (PORTB |=beep)
; #define beep_on() (PORTB &=~beep)
; 
; //8MHz时钟,1uS精确延时
; //#define delay_1us() asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop")
; 
; //7.3728MHz时钟,~1uS延时
; #define delay_1us() asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop")
; 
; 
; //延时N微秒
; void delay_us(uint us)
;    {
	xjmp L8
L7:
	.dbline 159
	.dbline 160
	nop
	.dbline 160
	nop
	.dbline 160
	nop
	.dbline 160
	nop
	.dbline 160
	nop
	.dbline 160
	nop
	.dbline 160
	nop
	.dbline 161
L8:
	.dbline 159
;    while(us--) {
	movw R2,R16
	subi R16,1
	sbci R17,0
	tst R2
	brne L7
	tst R3
	brne L7
X0:
	.dbline -2
L6:
	.dbline 0 ; func end
	ret
	.dbsym r us 16 i
	.dbend
	.dbfunc e delay_ms _delay_ms fV
;             ms -> R20,R21
	.even
_delay_ms::
	xcall push_gset1
	movw R20,R16
	.dbline -1
	.dbline 165
;       delay_1us();
;       }
;    }
; 
; //延时N毫秒   
; void delay_ms(uint ms) {
	xjmp L12
L11:
	.dbline 166
	.dbline 167
	ldi R16,1000
	ldi R17,3
	xcall _delay_us
	.dbline 168
L12:
	.dbline 166
;      while(ms--) {
	movw R2,R20
	subi R20,1
	sbci R21,0
	tst R2
	brne L11
	tst R3
	brne L11
X1:
	.dbline -2
L10:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r ms 20 i
	.dbend
	.dbfunc e beeps _beeps fV
;              i -> R20
	.even
_beeps::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 172
; 	    delay_us(1000);
; 	    } 
;      }
; 
; //蜂鸣器讯响 	 
; void beeps(unsigned char i) {      
	xjmp L16
L15:
	.dbline 173
	.dbline 174
	cbi 0x18,1
	.dbline 175
	ldi R16,30
	ldi R17,0
	xcall _delay_ms
	.dbline 176
	sbi 0x18,1
	.dbline 177
	ldi R16,30
	ldi R17,0
	xcall _delay_ms
	.dbline 178
L16:
	.dbline 173
;      while(i--) { 
	mov R2,R20
	clr R3
	subi R20,1
	tst R2
	brne L15
	.dbline -2
L14:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbend
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 188
; 	       beep_on();
; 	       delay_ms(30);
; 		   beep_off();
; 	       delay_ms(30);
; 		   }		   
;      }	    	 
; 
; //DDRxn    PortX    I/O     上拉  
; //  0        0      input    off       三态      
; //  0        1      input    on        弱上拉
; //  1        0      output   off       推挽0
; //  1        1      output   off       推挽1
; //端口初始化
; void port_init(void)
; {
	.dbline 189
;         PORTA = 0x1C;    //&B000,111,00                                          '0x1C
	ldi R24,28
	out 0x1b,R24
	.dbline 190
;         DDRA  = 0xE0;    //&B111,000,00  porta.7-porta.2 Kekyscan,1:0 ADC input  '0xE0
	ldi R24,224
	out 0x1a,R24
	.dbline 191
;         PORTB = 0xF3;    //portb.2,3=0
	ldi R24,243
	out 0x18,R24
	.dbline 192
;         DDRB  = 0xFE;   
	ldi R24,254
	out 0x17,R24
	.dbline 193
;         PORTC = 0xFF;    //m103 output only
	ldi R24,255
	out 0x15,R24
	.dbline 194
;         DDRC  = 0x00;
	clr R2
	out 0x14,R2
	.dbline 195
;         PORTD = 0xFF;
	out 0x12,R24
	.dbline 196
;         DDRD  = 0xFA;    //PD.0(RXD),PORTD.2(INT0)=input,&B1111,1010 
	ldi R24,250
	out 0x11,R24
	.dbline -2
L18:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e watchdog_init _watchdog_init fV
	.even
_watchdog_init::
	.dbline -1
	.dbline 202
; }
; 
; //Watchdog initialize
; // prescale: 2048K
; void watchdog_init(void)
; {
	.dbline 203
;  WDR(); //this prevents a timout on enabling
	wdr
	.dbline 204
;  WDTCR = 0x0F; //WATCHDOG ENABLED - dont forget to issue WDRs
	ldi R24,15
	out 0x21,R24
	.dbline -2
L19:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e timer0_init _timer0_init fV
	.even
_timer0_init::
	.dbline -1
	.dbline 212
; }
; 
; //TIMER0 initialize - prescale:Falling edge
; // WGM: Normal
; // desired value: 1Hz
; // actual value: Out of range
; void timer0_init(void)
; {
	.dbline 213
;  TCCR0 = 0x00; //stop
	clr R2
	out 0x33,R2
	.dbline 214
;  TCNT0 = 0x00 /*INVALID SETTING*/; //set count
	out 0x32,R2
	.dbline 215
;  OCR0  = 0x00 /*INVALID SETTING*/;  //set compare
	out 0x3c,R2
	.dbline 216
;  TCCR0 = 0x06; //start timer
	ldi R24,6
	out 0x33,R24
	.dbline -2
L20:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 44
	jmp _timer0_ovf_isr
	.area text(rom, con, rel)
	.dbfile F:\bss\AVR-ICC\qingxi\main.c
	.dbfunc e timer0_ovf_isr _timer0_ovf_isr fV
	.even
_timer0_ovf_isr::
	st -y,R2
	st -y,R24
	st -y,R25
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 222
; }
; 
; //T0计数器中断
; #pragma interrupt_handler timer0_ovf_isr:12
; void timer0_ovf_isr(void)
; {
	.dbline 223
;  Freq_H++;                           //外部脉冲计数用于测量频率                            
	lds R24,_Freq_H
	subi R24,255    ; addi 1
	sts _Freq_H,R24
	.dbline 224
;  TCNT0 = 0x00;                       //reload counter value
	clr R2
	out 0x32,R2
	.dbline -2
L21:
	ld R2,y+
	out 0x3f,R2
	ld R25,y+
	ld R24,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e timer1_init _timer1_init fV
	.even
_timer1_init::
	.dbline -1
	.dbline 233
; }
; 
; //*
; //7.3728MHz
; //TIMER1 initialize - prescale:1024
; // desired value: 100mSec
; // actual value: 100.000mSec (0.0%)
; void timer1_init(void)
; {
	.dbline 234
;  TCCR1B = 0x00; //stop
	clr R2
	out 0x2e,R2
	.dbline 235
;  TCNT1H = 0xFD; //setup
	ldi R24,253
	out 0x2d,R24
	.dbline 236
;  TCNT1L = 0x30;
	ldi R24,48
	out 0x2c,R24
	.dbline 237
;  OCR1AH = 0x02;
	ldi R24,2
	out 0x2b,R24
	.dbline 238
;  OCR1AL = 0xD0;
	ldi R24,208
	out 0x2a,R24
	.dbline 239
;  OCR1BH = 0x02;
	ldi R24,2
	out 0x29,R24
	.dbline 240
;  OCR1BL = 0xD0;
	ldi R24,208
	out 0x28,R24
	.dbline 241
;  ICR1H  = 0x02;
	ldi R24,2
	out 0x27,R24
	.dbline 242
;  ICR1L  = 0xD0;
	ldi R24,208
	out 0x26,R24
	.dbline 243
;  TCCR1A = 0x00;
	out 0x2f,R2
	.dbline 244
;  TCCR1B = 0x05; //start Timer
	ldi R24,5
	out 0x2e,R24
	.dbline -2
L22:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 36
	jmp _timer1_ovf_isr
	.area text(rom, con, rel)
	.dbfile F:\bss\AVR-ICC\qingxi\main.c
	.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
	.even
_timer1_ovf_isr::
	st -y,R2
	st -y,R3
	st -y,R4
	st -y,R5
	st -y,R16
	st -y,R17
	st -y,R18
	st -y,R19
	st -y,R24
	st -y,R25
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 251
; }
; //*/
; 
; 
; #pragma interrupt_handler timer1_ovf_isr:10
; void timer1_ovf_isr(void)
; {
	.dbline 253
;  //TIMER1 has overflowed
;  TCNT1H = 0xFD; //reload counter high value
	ldi R24,253
	out 0x2d,R24
	.dbline 254
;  TCNT1L = 0x30; //reload counter low value
	ldi R24,48
	out 0x2c,R24
	.dbline 256
;  //ms100_flag=1;   //100mS标志置位
;  UpdateFlag=1;   //100mS标志置位
	ldi R24,1
	sts _UpdateFlag,R24
	.dbline 257
;  if (S_flag<9) S_flag++;   //1S标志置位
	lds R24,_S_flag
	cpi R24,9
	brsh L24
	.dbline 257
	subi R24,255    ; addi 1
	sts _S_flag,R24
	xjmp L25
L24:
	.dbline 259
	.dbline 260
	clr R2
	out 0x32,R2
	.dbline 261
	sts _S_flag,R2
	.dbline 262
	lds R18,_Freq_H
	clr R19
	ldi R16,256
	ldi R17,1
	xcall empy16s
	movw R2,R16
	in R4,0x32
	clr R5
	add R2,R4
	adc R3,R5
	sts _Freq+1,R3
	sts _Freq,R2
	.dbline 263
	clr R2
	sts _Freq_H,R2
	.dbline 264
L25:
	.dbline -2
L23:
	ld R2,y+
	out 0x3f,R2
	ld R25,y+
	ld R24,y+
	ld R19,y+
	ld R18,y+
	ld R17,y+
	ld R16,y+
	ld R5,y+
	ld R4,y+
	ld R3,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e adc_init _adc_init fV
	.even
_adc_init::
	.dbline -1
	.dbline 271
;  else
;     {
; 	TCNT0=0;
; 	S_flag=0;
;     Freq=Freq_H*256+TCNT0;
; 	Freq_H=0;
; 	}   
; }
; //*/
; 
; //ADC initialize
; // Conversion time: 208uS
; void adc_init(void)
; {
	.dbline 272
;  ADCSR = 0x00; //disable adc
	clr R2
	out 0x6,R2
	.dbline 273
;  ADMUX = 0x00; //select adc input 0
	out 0x7,R2
	.dbline 274
;  ACSR  = 0x80;
	ldi R24,128
	out 0x8,R24
	.dbline 275
;  ADCSR = 0xEF; //0xEE
	ldi R24,239
	out 0x6,R24
	.dbline -2
L26:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 64
	jmp _adc_isr
	.area text(rom, con, rel)
	.dbfile F:\bss\AVR-ICC\qingxi\main.c
	.dbfunc e adc_isr _adc_isr fV
	.even
_adc_isr::
	.dbline -1
	.dbline 280
; }
; 
; #pragma interrupt_handler adc_isr:17
; void adc_isr(void)
; {
	.dbline -2
L27:
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e uart0_init _uart0_init fV
	.even
_uart0_init::
	.dbline -1
	.dbline 295
;  //conversion complete, read value (int) using...
;  //  readadc=ADCL;            //Read 8 low bits first (important)
; }
; 
; 
; //*/
; //串行通讯设置
; //UART0 initialize
; // 7.3728MHz
; // desired baud rate: 57600
; // actual: baud rate:57600 (0.0%)
; // char size: 8 bit
; // parity: Disabled
; void uart0_init(void)
; {
	.dbline 296
;  UCSRB = 0x00; //disable while setting baud rate
	clr R2
	out 0xa,R2
	.dbline 297
;  UCSRA = 0x00;
	out 0xb,R2
	.dbline 298

⌨️ 快捷键说明

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