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

📄 iic_test.s

📁 单片机为meg88
💻 S
字号:
	.module iic_test.c
	.area text(rom, con, rel)
	.dbfile C:\DOCUME~1\fengzm.POWERMAXTECH\桌面\MCU2\iic_test.c
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 14
; //ICC-AVR application builder : 2006-10-16 下午 09:35:42
; // Target : M88
; // Crystal: 20.0000Mhz
; 
; #include "common.h"
; 
; 
; void KeyScanTask1(void);
; void KeyScanTask2(void);
; void KeyPressedTask1(void);
; void KeyPressedTask2(void);
; 
; void port_init(void)
; {
	.dbline 15
; 	PORTB = 0x01;	   //只用PB0口,并且是输入口
	ldi R24,1
	out 0x5,R24
	.dbline 16
; 	DDRB  = 0xFE;	   //0是输入
	ldi R24,254
	out 0x4,R24
	.dbline 17
; 	PORTC = 0x08;	   //0000 1000//   PORTC |= 0x08; PORTC &= ~0x08;
	ldi R24,8
	out 0x8,R24
	.dbline 18
; 	DDRC  = 0x08;	   //1是输出 0000 1000
	out 0x7,R24
	.dbline 19
; 	PORTD = 0x00;
	clr R2
	out 0xb,R2
	.dbline 20
; 	DDRD  = 0x00;
	out 0xa,R2
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e timer0_init _timer0_init fV
	.even
_timer0_init::
	.dbline -1
	.dbline 28
; }
; 
; //TIMER0 initialize - prescale:64
; // WGM: Normal
; // desired value: 1mSec
; // actual value:  1.000mSec (0.0%)
; void timer0_init(void)
; {
	.dbline 29
; 	TCCR0B = 0x00; //stop
	clr R2
	out 0x25,R2
	.dbline 30
; 	TCNT0  = 0x83; //set count
	ldi R24,131
	out 0x26,R24
	.dbline 31
; 	TCCR0A = 0x00;
	out 0x24,R2
	.dbline 32
; 	TCCR0B = 0x03; //start timer
	ldi R24,3
	out 0x25,R24
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 32
	rjmp _timer0_ovf_isr
	.area text(rom, con, rel)
	.dbfile C:\DOCUME~1\fengzm.POWERMAXTECH\桌面\MCU2\iic_test.c
	.area data(ram, con, rel)
	.dbfile C:\DOCUME~1\fengzm.POWERMAXTECH\桌面\MCU2\iic_test.c
L4:
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile C:\DOCUME~1\fengzm.POWERMAXTECH\桌面\MCU2\iic_test.c
	.area text(rom, con, rel)
	.dbfile C:\DOCUME~1\fengzm.POWERMAXTECH\桌面\MCU2\iic_test.c
	.dbfunc e timer0_ovf_isr _timer0_ovf_isr fV
	.dbsym s s_unLoopTimeCnt L4 i
	.even
_timer0_ovf_isr::
	st -y,R2
	st -y,R3
	st -y,R24
	st -y,R25
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 38
	.dbline 41
	ldi R24,131
	out 0x26,R24
	.dbline 42
	lds R24,L4
	lds R25,L4+1
	adiw R24,1
	sts L4+1,R25
	sts L4,R24
	.dbline 43
	ldi R24,2
	ldi R25,0
	lds R2,L4
	lds R3,L4+1
	cp R24,R2
	cpc R25,R3
	brsh L5
	.dbline 44
	.dbline 45
	clr R2
	clr R3
	sts L4+1,R3
	sts L4,R2
	.dbline 46
	ldi R24,255
	sts _g_ucLoopTimeFlag,R24
	.dbline 47
L5:
	.dbline -2
L3:
	ld R2,y+
	out 0x3f,R2
	ld R25,y+
	ld R24,y+
	ld R3,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.area data(ram, con, rel)
	.dbfile C:\DOCUME~1\fengzm.POWERMAXTECH\桌面\MCU2\iic_test.c
L8:
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile C:\DOCUME~1\fengzm.POWERMAXTECH\桌面\MCU2\iic_test.c
L9:
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile C:\DOCUME~1\fengzm.POWERMAXTECH\桌面\MCU2\iic_test.c
L10:
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile C:\DOCUME~1\fengzm.POWERMAXTECH\桌面\MCU2\iic_test.c
	.area text(rom, con, rel)
	.dbfile C:\DOCUME~1\fengzm.POWERMAXTECH\桌面\MCU2\iic_test.c
	.dbfunc e KeyScanTask _KeyScanTask fV
	.dbsym s s_undisabletime L10 i
	.dbsym s s_ucKeyPressCnt L9 c
	.dbsym s s_ucKeyDitheringCnt L8 c
	.even
_KeyScanTask::
	.dbline -1
	.dbline 52
; }
; 
; 
; #pragma interrupt_handler timer0_ovf_isr:17		//TIMER0 has overflowed
; void timer0_ovf_isr(void)
; {
; 	static uint s_unLoopTimeCnt = 0;
; 
; 	TCNT0  = 0x83; 								//set count
; 	s_unLoopTimeCnt++;
; 	if(s_unLoopTimeCnt > 2)
; 	{
; 		s_unLoopTimeCnt = 0;
; 		g_ucLoopTimeFlag = true;
; 	}
; 
; }
; 
; void KeyScanTask(void)
; {
	.dbline 57
; 	static uchar s_ucKeyDitheringCnt = 0;		//avoid dithering
; 	static uchar s_ucKeyPressCnt = 0;			//count the sequence of the pressed key
; 	static uint s_undisabletime = 0;
; 
; 	if(PINB & 0x01)								//if the input voltage is high
	sbis 0x3,0
	rjmp L11
	.dbline 58
; 	{
	.dbline 59
; 		s_ucKeyDitheringCnt++;
	lds R24,L8
	subi R24,255    ; addi 1
	sts L8,R24
	.dbline 60
; 		if(s_ucKeyDitheringCnt > 5)				//delay time 5x2=10ms;avoid dithering
	ldi R24,5
	lds R2,L8
	cp R24,R2
	brsh L13
	.dbline 61
; 		{
	.dbline 62
; 			s_ucKeyDitheringCnt = 0;
	clr R2
	sts L8,R2
	.dbline 63
; 			if(PINB & 0x01)
	sbis 0x3,0
	rjmp L15
	.dbline 64
; 				g_ucKeyPressed = true;
	ldi R24,255
	sts _g_ucKeyPressed,R24
L15:
	.dbline 65
; 		}
L13:
	.dbline 66
; 		s_undisabletime = 0;
	clr R2
	clr R3
	sts L10+1,R3
	sts L10,R2
	.dbline 67
; 		PORTC |= 0x08;
	sbi 0x8,3
	.dbline 68
; 	}
	rjmp L12
L11:
	.dbline 70
; 	else
; 	{
	.dbline 71
; 		s_ucKeyDitheringCnt = 0;
	clr R2
	sts L8,R2
	.dbline 72
; 		s_undisabletime++;
	lds R24,L10
	lds R25,L10+1
	adiw R24,1
	sts L10+1,R25
	sts L10,R24
	.dbline 73
; 		if(s_undisabletime > 30000)
	ldi R24,30000
	ldi R25,117
	lds R2,L10
	lds R3,L10+1
	cp R24,R2
	cpc R25,R3
	brsh L17
	.dbline 74
; 		{
	.dbline 75
; 			s_undisabletime = 0;
	clr R2
	clr R3
	sts L10+1,R3
	sts L10,R2
	.dbline 76
; 			PORTC &= ~0x08;
	cbi 0x8,3
	.dbline 77
; 		}
L17:
	.dbline 79
; 
; 		if(g_ucKeyPressed)
	lds R2,_g_ucKeyPressed
	tst R2
	breq L19
	.dbline 80
; 		{
	.dbline 81
; 			s_ucKeyPressCnt++;
	lds R24,L9
	subi R24,255    ; addi 1
	sts L9,R24
	.dbline 82
; 			if(s_ucKeyPressCnt > 3)
	ldi R24,3
	lds R2,L9
	cp R24,R2
	brsh L21
	.dbline 83
; 				{
	.dbline 84
; 				s_ucKeyPressCnt = 1;
	ldi R24,1
	sts L9,R24
	.dbline 85
; 				g_ucFlashEnd = false;
	clr R2
	sts _g_ucFlashEnd,R2
	.dbline 86
; 			}
L21:
	.dbline 87
; 			g_ucKeyPressed = false;
	clr R2
	sts _g_ucKeyPressed,R2
	.dbline 88
; 		}
L19:
	.dbline 89
; 	}
L12:
	.dbline 90
; 	g_ucKeyPressedCnt = s_ucKeyPressCnt;
	lds R2,L9
	sts _g_ucKeyPressedCnt,R2
	.dbline -2
L7:
	.dbline 0 ; func end
	ret
	.dbend
	.area data(ram, con, rel)
	.dbfile C:\DOCUME~1\fengzm.POWERMAXTECH\桌面\MCU2\iic_test.c
L24:
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile C:\DOCUME~1\fengzm.POWERMAXTECH\桌面\MCU2\iic_test.c
L25:
	.blkb 1
	.area idata
	.byte 4
	.area data(ram, con, rel)
	.dbfile C:\DOCUME~1\fengzm.POWERMAXTECH\桌面\MCU2\iic_test.c
	.area text(rom, con, rel)
	.dbfile C:\DOCUME~1\fengzm.POWERMAXTECH\桌面\MCU2\iic_test.c
	.dbfunc e KeyPressedTask _KeyPressedTask fV
	.dbsym s s_ucLedFlashCnt L25 c
	.dbsym s s_unLedFlashTimeDly L24 i
	.even
_KeyPressedTask::
	sbiw R28,1
	.dbline -1
	.dbline 94
; }
; 
; void KeyPressedTask(void)
; {
	.dbline 97
; 	static uint  s_unLedFlashTimeDly = 0;
; 	static uchar s_ucLedFlashCnt = 4;
; 	if(g_ucKeyPressedCnt == 1)					//press the first
	lds R24,_g_ucKeyPressedCnt
	cpi R24,1
	brne L26
	.dbline 98
; 		IICSendStr(0x60,g_ucTorchIICData,2);
	ldi R24,2
	std y+0,R24
	ldi R18,<_g_ucTorchIICData
	ldi R19,>_g_ucTorchIICData
	ldi R16,96
	rcall _IICSendStr
	rjmp L27
L26:
	.dbline 99
; 	else if(g_ucKeyPressedCnt == 2)
	lds R24,_g_ucKeyPressedCnt
	cpi R24,2
	brne L28
	.dbline 100
; 		IICSendStr(0x60,g_ucLightOFFData,2);
	ldi R24,2
	std y+0,R24
	ldi R18,<_g_ucLightOFFData
	ldi R19,>_g_ucLightOFFData
	ldi R16,96
	rcall _IICSendStr
	rjmp L29
L28:
	.dbline 101
; 	else if((g_ucKeyPressedCnt == 3) && (!g_ucFlashEnd))		//press the second
	lds R24,_g_ucKeyPressedCnt
	cpi R24,3
	breq X0
	rjmp L30
X0:
	lds R2,_g_ucFlashEnd
	tst R2
	breq X1
	rjmp L30
X1:
	.dbline 102
; 	{
	.dbline 103
; 		if(s_ucLedFlashCnt > 0)
	clr R2
	lds R3,L25
	cp R2,R3
	brsh L32
	.dbline 104
; 		{
	.dbline 105
; 			s_unLedFlashTimeDly++;
	lds R24,L24
	lds R25,L24+1
	adiw R24,1
	sts L24+1,R25
	sts L24,R24
	.dbline 106
; 			if(s_unLedFlashTimeDly < 50)
	cpi R24,50
	ldi R30,0
	cpc R25,R30
	brsh L34
	.dbline 107
; 				IICSendStr(0x60,g_ucIledIICData,2);		//led is on
	ldi R24,2
	std y+0,R24
	ldi R18,<_g_ucIledIICData
	ldi R19,>_g_ucIledIICData
	ldi R16,96
	rcall _IICSendStr
	rjmp L33
L34:
	.dbline 108
; 			else if(s_unLedFlashTimeDly < 100)
	lds R24,L24
	lds R25,L24+1
	cpi R24,100
	ldi R30,0
	cpc R25,R30
	brsh L36
	.dbline 109
; 				IICSendStr(0x60,g_ucLightOFFData,2);	//led is off
	ldi R24,2
	std y+0,R24
	ldi R18,<_g_ucLightOFFData
	ldi R19,>_g_ucLightOFFData
	ldi R16,96
	rcall _IICSendStr
	rjmp L33
L36:
	.dbline 111
; 			else
; 			{
	.dbline 112
; 				s_unLedFlashTimeDly = 0;
	clr R2
	clr R3
	sts L24+1,R3
	sts L24,R2
	.dbline 113
; 				s_ucLedFlashCnt--;
	lds R24,L25
	subi R24,1
	sts L25,R24
	.dbline 114
; 			}
	.dbline 115
; 		}
	rjmp L33
L32:
	.dbline 117
; 		else
; 		{
	.dbline 118
; 			s_ucLedFlashCnt = 4;
	ldi R24,4
	sts L25,R24
	.dbline 119
; 			g_ucFlashEnd = true;
	ldi R24,255
	sts _g_ucFlashEnd,R24
	.dbline 120
; 			IICSendStr(0x60,g_ucFlashEnIICData,2);		//enalble flash
	ldi R24,2
	std y+0,R24
	ldi R18,<_g_ucFlashEnIICData
	ldi R19,>_g_ucFlashEnIICData
	ldi R16,96
	rcall _IICSendStr
	.dbline 121
; 			IICSendStr(0x60,g_ucFlashTimerIICData,2);
	ldi R24,2
	std y+0,R24
	ldi R18,<_g_ucFlashTimerIICData
	ldi R19,>_g_ucFlashTimerIICData
	ldi R16,96
	rcall _IICSendStr
	.dbline 122
; 			IICSendStr(0x60,g_ucFlashIICData,2);		//flash is on
	ldi R24,2
	std y+0,R24
	ldi R18,<_g_ucFlashIICData
	ldi R19,>_g_ucFlashIICData
	ldi R16,96
	rcall _IICSendStr
	.dbline 123
; 		}
L33:
	.dbline 124
; 	}
L30:
L29:
L27:
	.dbline -2
L23:
	adiw R28,1
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 129
; }
; 
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
	.dbline 131
; //stop errant interrupts until set up
; 	CLI(); //disable all interrupts
	cli
	.dbline 132
; 	port_init();
	rcall _port_init
	.dbline 133
; 	twi_init();
	rcall _twi_init
	.dbline 134
; 	timer0_init();
	rcall _timer0_init
	.dbline 136
; 
; 	MCUCR = 0x00;
	clr R2
	out 0x35,R2
	.dbline 137
; 	EICRA = 0x0A;	//extended ext ints
	ldi R24,10
	sts 105,R24
	.dbline 138
; 	EIMSK = 0x03;
	ldi R24,3
	out 0x1d,R24
	.dbline 140
; 
; 	TIMSK0 = 0x01;	//timer 0 interrupt sources
	ldi R24,1
	sts 110,R24
	.dbline 141
; 	TIMSK1 = 0x21;	//timer 1 interrupt sources
	ldi R24,33
	sts 111,R24
	.dbline 142
; 	TIMSK2 = 0x01;	//timer 2 interrupt sources
	ldi R24,1
	sts 112,R24
	.dbline 144
; 
; 	PCMSK0 = 0x02;	//pin change mask 0			//允许外部电平中断
	ldi R24,2
	sts 107,R24
	.dbline 145
; 	PCMSK1 = 0x02;	//pin change mask 1
	sts 108,R24
	.dbline 146
; 	PCMSK2 = 0x00;	//pin change mask
	sts 109,R2
	.dbline 147
; 	PCICR  = 0x03;	//pin change enable
	ldi R24,3
	sts 104,R24
	.dbline 148
; 	PRR    = 0x00;	//power controller
	sts 100,R2
	.dbline 149
; 	SEI(); //re-enable interrupts
	sei
	.dbline -2
L38:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 154
; //all peripherals are now initialized
; }
; 
; void main(void)
; {
	.dbline 155
; 	init_devices();
	rcall _init_devices
	rjmp L41
L40:
	.dbline 158
; 
; 	while(1)
; 	{
	.dbline 159
; 		if(g_ucLoopTimeFlag)
	lds R2,_g_ucLoopTimeFlag
	tst R2
	breq L43
	.dbline 160
; 		{
	.dbline 161
; 			g_ucLoopTimeFlag = false;
	clr R2
	sts _g_ucLoopTimeFlag,R2
	.dbline 163
; //			disablechip();
; 			KeyScanTask();					//key scan
	rcall _KeyScanTask
	.dbline 164
; 			KeyPressedTask();				//key process
	rcall _KeyPressedTask
	.dbline 165
; 		}
L43:
	.dbline 166
L41:
	.dbline 157
	rjmp L40
X2:
	.dbline -2
L39:
	.dbline 0 ; func end
	ret
	.dbend

⌨️ 快捷键说明

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