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

📄 main.s

📁 我写的atmega16驱动的nrf24l01程序
💻 S
📖 第 1 页 / 共 4 页
字号:
	.module main.c
	.area vector(rom, abs)
	.org 4
	jmp _INT_EX0
	.org 36
	jmp _INT_Timer0
	.org 32
	jmp _INT_Timer1
	.org 44
	jmp _INT_USART_RX
	.org 52
	jmp _INT_USART_TX
	.org 40
	jmp _spi_stc_isr
	.area eeprom(rom, con, rel)
_II2C_Test::
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0
	.dbfile D:\mywork\无绳电话\NRF2401\nRF24L01_atmega16\nrf24l01/WDCT_02.h
	.dbsym e II2C_Test _II2C_Test A[15:15]c
_II2C_UserConfig::
	.byte 15,15
	.byte 1,3
	.byte 10,64
	.byte 7,'p
	.byte 0,0
	.byte 0,0
	.byte 195,196
	.byte 197,198
	.byte 0,32
	.byte 32,32
	.byte 32,32
	.byte 32,0
	.dbsym e II2C_UserConfig _II2C_UserConfig A[24:24]c
_II2C_RxPipe0Addr::
	.byte 1,2
	.byte 3,4
	.byte 5
	.dbsym e II2C_RxPipe0Addr _II2C_RxPipe0Addr A[5:5]c
_II2C_RxPipe1Addr::
	.byte 1,2
	.byte 3,4
	.byte 6
	.dbsym e II2C_RxPipe1Addr _II2C_RxPipe1Addr A[5:5]c
_II2C_TxPipeAddr::
	.byte 1,2
	.byte 3,4
	.byte 5
	.dbsym e II2C_TxPipeAddr _II2C_TxPipeAddr A[5:5]c
	.area data(ram, con, rel)
	.dbfile D:\mywork\无绳电话\NRF2401\nRF24L01_atmega16\nrf24l01/WDCT_02.h
	.area text(rom, con, rel)
	.dbfile D:\mywork\无绳电话\NRF2401\nRF24L01_atmega16\nrf24l01/WDCT_02.h
	.dbfile D:\mywork\无绳电话\NRF2401\nRF24L01_atmega16\nrf24l01/init.c
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 9
; 
; #include "WDCT_02.h"	
; #include "init.c"		
; #include "key.c"	    
; #include "int.c"	   	
; #include "nrf24l01.c"
; #include "deal.c"
;  	
; 
	.dbline 10
; 
	ldi R24,239
	out 0x18,R24
	.dbline 11
; 
	ldi R24,187
	out 0x17,R24
	.dbline 13
; 
; //--------------------------------------------------------
	ldi R24,255
	out 0x15,R24
	.dbline 14
; //--------------------------------------------------------
	ldi R24,254
	out 0x14,R24
	.dbline 15
; void main(void)
	out 0x12,R24
	.dbline 16
; {
	ldi R24,250
	out 0x11,R24
	.dbline -2
	.dbline 17
; unsigned char i;	
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e watchdog_init _watchdog_init fV
	.even
_watchdog_init::
	.dbline -1
	.dbline 27
; 	init_devices();
; 	
; 	SPI_MasterInit();
; //	_ClrNRF_SS;
; //	while(1);
; 	bSignal2Hz=0;
; 	bTest=0;
; 	ComRxCount=0;
; 	_ClrNRF_CE;//standby mode 
; 	nrf24l01_init();
	.dbline 28
; 	while(1)
	wdr
	.dbline 29
; 	{
	ldi R24,8
	out 0x21,R24
	.dbline -2
	.dbline 30
; //	_ClrNRF_SS;
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e SPI_MasterInit _SPI_MasterInit fV
	.even
_SPI_MasterInit::
	.dbline -1
	.dbline 38
; 		if(bKeyGetted == dTrue)	
; 		{
; 			switch (KeyValue)
; 			{
; 				case dKeyE:nrf24l01_init();;break;
; 				case dKey5:ReadRegisters();break;
; 				case dKey6:SendTest();break;
; 				case dKey7:SetRxMode();break;
	.dbline 39
; 				case dKey8:SetTxMode();break;
	sbi 0x18,3
	.dbline 40
; 				case dKeyD:ReadNextRegister();break;
	nop
	.dbline 40
	nop
	.dbline 40
	nop
	.dbline 41
; //				case dKeyE:ReadLastRegister();break;
	in R24,0x17
	ori R24,168
	out 0x17,R24
	.dbline 42
; 				default:break;
	cbi 0x17,6
	.dbline 43
; 			}
	ldi R24,81
	out 0xd,R24
	.dbline -2
	.dbline 44
; 
L3:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e InitInterrupt _InitInterrupt fV
	.even
_InitInterrupt::
	.dbline -1
	.dbline 53
; 
; 			bKeyGetted = dFalse;	
; 		}
; 		if(bTime2ms==dTrue)
; 		{
; 			FlashLed();
; 			
; 			if(bComRxing==dTrue)
; 			{
	.dbline 54
; 				ComRxingTimeLimited++;
	ldi R24,128
	out 0x20,R24
	.dbline 55
; 				if(ComRxingTimeLimited>=50)//100ms没收到数据认为接受结束
	ldi R24,134
	out 0x20,R24
	.dbline 56
; 				{
	ldi R24,207
	out 0x9,R24
	.dbline 57
; 					bComRxing=dFalse;
	ldi R24,134
	out 0x20,R24
	.dbline 58
; 					bCom2Spi=dTrue;
	ldi R24,207
	out 0x9,R24
	.dbline 60
; 				}
; 				
	ldi R24,32
	out 0xb,R24
	.dbline 61
; 			}
	ldi R24,216
	out 0xa,R24
	.dbline 63
; 			
; 			bTime2ms=dFalse;	
	ldi R24,128
	out 0x20,R24
	.dbline 64
; 		}	
	ldi R24,134
	out 0x20,R24
	.dbline 65
; //	_SetNRF_SS;
	ldi R24,207
	out 0x9,R24
	.dbline 67
; 		
; 		if((bCom2Spi == dTrue) && (bSpiTxing == dFalse))
	clr R2
	out 0x33,R2
	.dbline 68
; 		{
	ldi R24,130
	out 0x32,R24
	.dbline 69
; 			ComDeal();
	ldi R24,3
	out 0x33,R24
	.dbline 71
; 		}
; 		
	out 0x2e,R2
	.dbline 72
; 		if(bEx0Interrupt == dTrue)
	ldi R24,248
	out 0x2d,R24
	.dbline 73
; 		{
	ldi R24,47
	out 0x2c,R24
	.dbline 74
; 			bEx0Interrupt = dFalse;
	out 0x2f,R2
	.dbline 75
; 			Ex0Deal();
	ldi R24,2
	out 0x2e,R24
	.dbline 77
; 		}
; 		WDR();
	out 0x35,R24
	.dbline 78
; 	}
	ldi R24,64
	out 0x3b,R24
	.dbline 79
; }
	ldi R24,5
	out 0x39,R24
	.dbline -2
	.dbline 80
; }
L4:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 88
; }
; }
; }
; }
; }
; }
; }
; }
	.dbline 90
; }
; }
	cli
	.dbline 91
; }
	xcall _port_init
	.dbline 92
; }
	xcall _watchdog_init
	.dbline 93
; }
	xcall _InitInterrupt
	.dbline 95
; }
; }
	ldi R24,2
	out 0x35,R24
	.dbline 97
; }
; }
	ldi R24,5
	out 0x39,R24
	.dbline 98
; }
	sei
	.dbline -2
	.dbline 100
; }
; }
L5:
	.dbline 0 ; func end
	ret
	.dbend
	.area lit(rom, con, rel)
_KeycodeNum::
	.byte 238,'w
	.byte 183,215
	.byte 231,123
	.byte 187,219
	.byte 235,125
	.byte 189,221
	.byte 237,126
	.byte 190,222
	.dbfile D:\mywork\无绳电话\NRF2401\nRF24L01_atmega16\nrf24l01/key.c
	.dbsym e KeycodeNum _KeycodeNum A[16:16]kc
	.area text(rom, con, rel)
	.dbfile D:\mywork\无绳电话\NRF2401\nRF24L01_atmega16\nrf24l01/key.c
	.dbfunc e INT_KeyTest _INT_KeyTest fV
;    KeyCodeTemp -> R16
;              j -> R16
;        KeyCode -> R18
;              i -> R16
	.even
_INT_KeyTest::
	.dbline -1
	.dbline 29
	.dbline 32
	ldi R24,240
	out 0x1b,R24
	.dbline 33
	nop
	.dbline 33
	nop
	.dbline 33
	nop
	.dbline 34
	nop
	.dbline 34
	nop
	.dbline 34
	nop
	.dbline 35
	nop
	.dbline 35
	nop
	.dbline 35
	nop
	.dbline 36
	ldi R24,15
	out 0x1a,R24
	.dbline 37
	nop
	.dbline 37
	nop
	.dbline 37
	nop
	.dbline 38
	nop
	.dbline 38
	nop
	.dbline 38
	nop
	.dbline 39
	nop
	.dbline 39
	nop
	.dbline 39
	nop
	.dbline 40
	in R16,0x19
	andi R16,240
	.dbline 41
	cpi R16,240
	brne L7
	.dbline 42
	.dbline 43
	sts _KeyBeforeCodeTemp,R16
	.dbline 44
	clr R2
	sts _KeyDelayCou,R2
	.dbline 45
	sts _bKeyPress,R2
	.dbline 46
	xjmp L6
L7:
	.dbline 51
	sts _KeyBeforeCodeTemp,R16
	.dbline 52
	lds R2,_bKeyPress
	tst R2
	breq L9
	.dbline 52
	xjmp L6
L9:
	.dbline 53
	lds R24,_KeyDelayCou
	cpi R24,64
	brsh L11
	.dbline 54
	.dbline 55
	subi R24,255    ; addi 1
	sts _KeyDelayCou,R24
	.dbline 56
	xjmp L6
L11:
	.dbline 58
	.dbline 58
	ldi R24,85
	sts _bKeyPress,R24
	.dbline 58
	clr R2
	sts _KeyDelayCou,R2
	.dbline 58
	.dbline 60
	lds R24,_bKeyGetted
	cpi R24,85
	brne L13
	.dbline 60
	xjmp L6
L13:
	.dbline 65
	ldi R24,240
	out 0x1b,R24
	.dbline 66
	nop
	.dbline 66
	nop
	.dbline 66
	nop
	.dbline 67
	nop
	.dbline 67
	nop
	.dbline 67
	nop
	.dbline 68
	nop
	.dbline 68
	nop
	.dbline 68
	nop
	.dbline 69
	ldi R24,15
	out 0x1a,R24
	.dbline 70
	nop
	.dbline 70
	nop
	.dbline 70
	nop
	.dbline 71
	nop
	.dbline 71
	nop
	.dbline 71
	nop
	.dbline 72
	nop
	.dbline 72
	nop
	.dbline 72
	nop
	.dbline 73
	in R18,0x19
	andi R18,240
	.dbline 75
	out 0x1b,R24
	.dbline 76
	nop
	.dbline 76
	nop
	.dbline 76
	nop
	.dbline 77
	nop
	.dbline 77
	nop
	.dbline 77
	nop
	.dbline 78
	ldi R24,240
	out 0x1a,R24
	.dbline 79
	nop
	.dbline 79
	nop
	.dbline 79
	nop
	.dbline 80
	nop
	.dbline 80
	nop
	.dbline 80
	nop
	.dbline 81
	nop
	.dbline 81
	nop
	.dbline 81
	nop
	.dbline 82
	in R16,0x19
	andi R16,15
	.dbline 84
	add R18,R16
	.dbline 89
	clr R16
	xjmp L18
L15:
	.dbline 90
	.dbline 91
	ldi R24,<_KeycodeNum
	ldi R25,>_KeycodeNum
	mov R30,R16
	clr R31
	add R30,R24
	adc R31,R25
	lpm R30,Z
	cp R18,R30
	brne L19
	.dbline 92
	.dbline 93
	sts _KeyValue,R16
	.dbline 94
	ldi R24,85
	sts _bKeyGetted,R24
	.dbline 95
	xjmp L17
L19:
	.dbline 97
	inc R16
	.dbline 98
L16:
	.dbline 89
L18:
	.dbline 89
	cpi R16,16
	brlo L15
L17:
	.dbline -2
	.dbline 99
L6:
	.dbline 0 ; func end
	ret
	.dbsym r KeyCodeTemp 16 c
	.dbsym r j 16 c
	.dbsym r KeyCode 18 c
	.dbsym r i 16 c
	.dbend
	.dbfile D:\mywork\无绳电话\NRF2401\nRF24L01_atmega16\nrf24l01/int.c
	.dbfunc e INT_Timer0 _INT_Timer0 fV
	.even
_INT_Timer0::
	st -y,R24
	in R24,0x3f
	st -y,R24
	.dbline -1
	.dbline 4
	.dbline 5
	ldi R24,6
	out 0x32,R24
	.dbline -2
	.dbline 6
L21:
	ld R24,y+
	out 0x3f,R24
	ld R24,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e INT_Timer1 _INT_Timer1 fV
	.even
_INT_Timer1::
	xcall push_lset
	.dbline -1
	.dbline 8
	.dbline 10
	ldi R24,248
	out 0x2d,R24
	.dbline 11
	ldi R24,47
	out 0x2c,R24
	.dbline 12
	ldi R24,85
	sts _bTime2ms,R24
	.dbline 14
	lds R24,_bBusy
	cpi R24,85
	breq L23
	.dbline 14
	xcall _INT_KeyTest
L23:
	.dbline -2
	.dbline 15
L22:
	xcall pop_lset
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e INT_USART_RX _INT_USART_RX fV
	.even
_INT_USART_RX::
	st -y,R2
	st -y,R3
	st -y,R24
	st -y,R25
	st -y,R30
	st -y,R31
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 23
	.dbline 24
	lds R24,_bCom2Spi
	cpi R24,85
	brne L26
	.dbline 24
	xjmp L25
L26:
	.dbline 25
	ldi R24,<_ComRxBuf
	ldi R25,>_ComRxBuf
	lds R30,_ComRxCount
	clr R31
	add R30,R24
	adc R31,R25
	in R2,0xc
	std z+0,R2
	.dbline 26
	lds R24,_ComRxCount
	subi R24,255    ; addi 1
	sts _ComRxCount,R24
	.dbline 27
	clr R2
	clr R3
	sts _ComRxingTimeLimited+1,R3
	sts _ComRxingTimeLimited,R2
	.dbline 28
	ldi R24,85
	sts _bComRxing,R24
	.dbline -2
	.dbline 29
L25:
	ld R2,y+
	out 0x3f,R2
	ld R31,y+
	ld R30,y+
	ld R25,y+
	ld R24,y+
	ld R3,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e INT_USART_TX _INT_USART_TX fV
	.even
_INT_USART_TX::
	st -y,R2
	st -y,R3
	st -y,R24
	st -y,R30
	st -y,R31
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 38
	.dbline 39
	clr R2
	lds R3,_ComTxCount
	cp R2,R3
	brsh L29
	.dbline 40
	.dbline 41
	mov R24,R3
	subi R24,1
	sts _ComTxCount,R24
	.dbline 42
	lds R30,_PtComTx
	lds R31,_PtComTx+1
	ld R2,Z+
	sts _PtComTx+1,R31
	sts _PtComTx,R30
	out 0xc,R2
	.dbline 43
L29:
	.dbline -2
	.dbline 44
L28:
	ld R2,y+
	out 0x3f,R2
	ld R31,y+
	ld R30,y+
	ld R24,y+
	ld R3,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e spi_stc_isr _spi_stc_isr fV
	.even
_spi_stc_isr::
	.dbline -1
	.dbline 48
	.dbline -2
	.dbline 50
L31:
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e INT_EX0 _INT_EX0 fV
	.even
_INT_EX0::
	st -y,R24
	in R24,0x3f
	st -y,R24
	.dbline -1
	.dbline 54
	.dbline 55
	ldi R24,85
	sts _bEx0Interrupt,R24
	.dbline -2
	.dbline 57
L32:
	ld R24,y+
	out 0x3f,R24
	ld R24,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfile D:\mywork\无绳电话\NRF2401\nRF24L01_atmega16\nrf24l01/nrf24l01.c
	.dbfunc e SPI_SendData _SPI_SendData fV
;              i -> R20
;             No -> R22
;       nrfRxBuf -> R18,R19
;       nrfTxBuf -> R16,R17
	.even
_SPI_SendData::
	xcall push_gset2
	ldd R22,y+4
	.dbline -1
	.dbline 5
	.dbline 8
	cbi 0x18,4
	.dbline 10
	ldi R24,85
	sts _bSpiTxing,R24
	.dbline 11
	clr R20
	xjmp L37
L34:
	.dbline 12
	.dbline 13
	mov R30,R20
	clr R31
	add R30,R16
	adc R31,R17
	ldd R2,z+0
	out 0xf,R2
	xjmp L39
L38:
	.dbline 14
	wdr
L39:
	.dbline 14
	sbis 0xe,7
	rjmp L38
	.dbline 15
	mov R30,R20
	clr R31
	add R30,R18
	adc R31,R19
	in R2,0xf
	std z+0,R2
	.dbline 16
L35:
	.dbline 11

⌨️ 快捷键说明

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