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

📄 demoa-16sm.s

📁 大量ATMEGA16实例, 都可以运行,包括驱动LCD1602, 上位机显示等多功能
💻 S
字号:
	.module DEMOA-16sm.c
	.area text(rom, con, rel)
	.dbfile C:\+samples-16small\DEMOA-16sm\DEMOA-16sm.c
	.dbfunc e main _main fV
;              a -> <dead>
;         array1 -> y+0
;          jsave -> <dead>
;              j -> <dead>
;           dark -> <dead>
;           pfin -> <dead>
;           data -> <dead>
;              i -> R10,R11
;         darkfg -> R20
	.even
_main::
	sbiw R28,10
	.dbline -1
	.dbline 77
; /*
; Title:	DEMOA-16sm.c
; Connection:
; 	  Factory fixed setting:
; 	  PORTA:
; 	  		PA0-PA2 LCD control
; 			PA3-PA7 4x7-segment display control
; 			Drive LED group2 (the right group of LED)
; 	  PORTB:
; 	  		Shared by LCD and 4x7-segment displays
; 	  		output 8-bit data to LCD or 8-bit data to 4x7-segment displays
; 	  PORTC:
; 	        shared by 8-bit dipswitch and 4 x touch switches + 4 buttons
; 			receive inputs from dipswitch, touch switches and buttons 				
; 	  PORTD: 
; 	  		Drive LED group1 (the left group of LED) 
; Attention:
; 	  1. J12 should be capped (connectted)
; 	  2. J5 is the Jump for LCD back light power 	  
; 
; Operation:
; 	  See the User Mannual, which is included in CD
; */
; 
; #include <iom16v.h>
; #include <macros.h>
; #include <stdlib.h>
; 
; // external symbols defined in LCD-avr-sm.c
; extern unsigned char lcd_enable, lcd_disable;
; extern unsigned char in_instr_wr, in_data_wr;
; extern unsigned char in_instr_rd, in_data_rd;
; extern void wr_instruction(unsigned char instr);
; extern void wr_data(unsigned char data);
; extern int indexhead, indextail, indexcount;
; extern int cursor_index;
; extern unsigned char swin, swin2;
; extern const char message1[];
; extern const char message2[]; 
; extern const char message3[];
; extern const char message4[];
; extern const char message5[];
; extern const char message6[];
; extern const char message7[];
; extern const char message8[];
; 
; extern void port_init(void);
; extern void WDT_off(void);
; extern void lcd_delay(int count);
; extern void ldelay(int ms);
; extern void wr_instruction(unsigned char instr);
; extern void wr_data(unsigned char data);
; extern void wr_instruction2(unsigned char instr);
; extern void wr_data2(unsigned char data);
; extern void cursor_home(void);			
; extern void cursor_line1(void);		  
; extern void cursor_line2(void);		
; extern void space(void);				  
; extern void out_string(const char array[]); 
; extern void lcd_on(void);
; 
; // External symboles defined in SegDisp-avr-fn.c
; 
; extern const char dig0, dig1, dig2, dig3, dot;
; extern char segconv[];
; extern unsigned char BCD0, BCD1, BCD2, BCD3;
; extern int count;
; 
; //extern void port_init(void);
; extern void delay(int count);
; extern void BinToBCD(int data);
; extern void dispseg(void);
; 
; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; 
; void main(void)
; {
	.dbline 78
;  unsigned char data, pfin, dark, darkfg=0xff;
	ldi R20,255
	.dbline 79
;  int i=0;
	clr R10
	clr R11
	.dbline 82
;  unsigned char j, jsave, array1[10];
;  int a;
;  CLI();
	cli
	.dbline 83
;  port_init();
	xcall _port_init
	.dbline 84
;  WDT_off();
	xcall _WDT_off
	.dbline 85
;  ldelay(200);
	ldi R16,200
	ldi R17,0
	xcall _ldelay
	.dbline 86
;  lcd_on();
	xcall _lcd_on
	.dbline 87
;  PORTD=0x50;
	ldi R24,80
	out 0x12,R24
	.dbline 88
;  ldelay(50);
	ldi R16,50
	ldi R17,0
	xcall _ldelay
	.dbline 89
;  PORTD=0x05;
	ldi R24,5
	out 0x12,R24
	.dbline 90
;  ldelay(50);
	ldi R16,50
	ldi R17,0
	xcall _ldelay
	.dbline 91
;  out_string(message1);
	ldi R16,<_message1
	ldi R17,>_message1
	xcall _out_string
	.dbline 92
;  cursor_line2();
	xcall _cursor_line2
	.dbline 93
;  out_string(message2);
	ldi R16,<_message2
	ldi R17,>_message2
	xcall _out_string
	.dbline 94
;  PORTD=0x55;
	ldi R24,85
	out 0x12,R24
	.dbline 95
;  PORTA=0xF8;
	ldi R24,248
	out 0x1b,R24
	.dbline 96
;  PORTB=0x00;
	clr R2
	out 0x18,R2
	.dbline 97
;  ldelay(100);
	ldi R16,100
	ldi R17,0
	xcall _ldelay
	xjmp L3
L2:
	.dbline 100
; 
;  while(1)
;  {
	.dbline 101
;   WDR();
	wdr
	.dbline 102
;   swin=PINC&0x30;
	in R24,0x13
	andi R24,48
	sts _swin,R24
	.dbline 103
;   swin=(swin>>4)&0x03;
	swap R24
	andi R24,#0x0F
	andi R24,3
	sts _swin,R24
	.dbline 104
;   if(swin2!=swin)
	mov R2,R24
	lds R3,_swin2
	cp R3,R24
	brne X5
	xjmp L5
X5:
X0:
	.dbline 105
;     {
	.dbline 106
; 	 swin2=swin;
	sts _swin2,R2
	.dbline 107
;   	 if(swin==0x00)
	tst R24
	brne L7
X1:
	.dbline 108
;       {
	.dbline 109
; 	  cursor_home();
	xcall _cursor_home
	.dbline 110
; 	  out_string(message1);
	ldi R16,<_message1
	ldi R17,>_message1
	xcall _out_string
	.dbline 111
;  	  cursor_line2();
	xcall _cursor_line2
	.dbline 112
;  	  out_string(message2);
	ldi R16,<_message2
	ldi R17,>_message2
	xcall _out_string
	.dbline 113
; 	  }
	xjmp L8
L7:
	.dbline 114
;   	 else if(swin==0x01)
	lds R24,_swin
	cpi R24,1
	brne L9
X2:
	.dbline 115
;       {
	.dbline 116
; 	  cursor_home();
	xcall _cursor_home
	.dbline 117
; 	  out_string(message3);
	ldi R16,<_message3
	ldi R17,>_message3
	xcall _out_string
	.dbline 118
;  	  cursor_line2();
	xcall _cursor_line2
	.dbline 119
;  	  out_string(message4);
	ldi R16,<_message4
	ldi R17,>_message4
	xcall _out_string
	.dbline 120
; 	  }
	xjmp L10
L9:
	.dbline 121
;      else if(swin==0x02)
	lds R24,_swin
	cpi R24,2
	brne L11
X3:
	.dbline 122
;       {
	.dbline 123
; 	  cursor_home();
	xcall _cursor_home
	.dbline 124
; 	  out_string(message5);
	ldi R16,<_message5
	ldi R17,>_message5
	xcall _out_string
	.dbline 125
;  	  cursor_line2();
	xcall _cursor_line2
	.dbline 126
;  	  out_string(message6);
	ldi R16,<_message6
	ldi R17,>_message6
	xcall _out_string
	.dbline 127
; 	  }
	xjmp L12
L11:
	.dbline 129
;      else
;       {
	.dbline 130
; 	  cursor_home();
	xcall _cursor_home
	.dbline 131
; 	  out_string(message7);
	ldi R16,<_message7
	ldi R17,>_message7
	xcall _out_string
	.dbline 132
;  	  cursor_line2();
	xcall _cursor_line2
	.dbline 133
;  	  out_string(message8);
	ldi R16,<_message8
	ldi R17,>_message8
	xcall _out_string
	.dbline 134
; 	  }		
L12:
L10:
L8:
	.dbline 135
; 	}
L5:
	.dbline 136
; 	swin=PINC;
	in R2,0x13
	sts _swin,R2
	.dbline 137
; 	BinToBCD(swin);
	mov R16,R2
	clr R17
	xcall _BinToBCD
	.dbline 138
; 	dispseg();	
	xcall _dispseg
	.dbline 139
;   }
L3:
	.dbline 99
	xjmp L2
X4:
	.dbline -2
L1:
	.dbline 0 ; func end
	adiw R28,10
	ret
	.dbsym l a 1 I
	.dbsym l array1 0 A[10:10]c
	.dbsym l jsave 1 c
	.dbsym l j 1 c
	.dbsym l dark 1 c
	.dbsym l pfin 1 c
	.dbsym l data 1 c
	.dbsym r i 10 I
	.dbsym r darkfg 20 c
	.dbend
; } 
; 

⌨️ 快捷键说明

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