📄 main.s
字号:
.module main.c
.area text(rom, con, rel)
.dbfile E:\公司用\atmega8l\final\nrf905_send1\main.c
.dbfunc e port_init1 _port_init1 fV
.even
_port_init1::
.dbline -1
.dbline 16
; //ICC-AVR application builder : 2006-4-4 11:28:26
; // Target : M16 PTR8000模块简单测试
; // Crystal: 4MHz(11.059Mhz)
;
; //最关键的是SPI的初始化,MSB首位和极性方式00,极性方式错误,数据则不正确
;
; #include "confg.h"
;
;
; #define MASTER //编译控制是主机还是从机
;
;
; void SystemIni(void);
;
; void port_init1(void)
; {
.dbline 17
; PORTB = 0xFe;
ldi R24,254
out 0x18,R24
.dbline 18
; DDRB = 0x00;
clr R2
out 0x17,R2
.dbline 19
; PORTC = 0x00; //m103 output only
out 0x15,R2
.dbline 20
; DDRC = 0x00;
out 0x14,R2
.dbline 21
; PORTD = 0xFF;
ldi R24,255
out 0x12,R24
.dbline 22
; DDRD = 0x00;
out 0x11,R2
.dbline -2
.dbline 23
; }
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e port_init2 _port_init2 fV
.even
_port_init2::
.dbline -1
.dbline 26
;
; void port_init2(void)
; {
.dbline 28
;
; PORTB = 0xD7;
ldi R24,215
out 0x18,R24
.dbline 29
; DDRB = 0x2C;
ldi R24,44
out 0x17,R24
.dbline 30
; PORTC = 0x00; //m103 output only
clr R2
out 0x15,R2
.dbline 31
; DDRC = 0x00;
out 0x14,R2
.dbline 32
; PORTD = 0x1f;
ldi R24,31
out 0x12,R24
.dbline 33
; DDRD = 0xe0;
ldi R24,224
out 0x11,R24
.dbline -2
.dbline 34
; }
L2:
.dbline 0 ; func end
ret
.dbend
.dbfunc e spi_init _spi_init fV
; temp -> R16
.even
_spi_init::
.dbline -1
.dbline 38
;
; //SPI initialize
; void spi_init(void)
; {uchar temp;
.dbline 41
;
; //SPCR = 0xD1; //SPI中断允许,SPI允许,主机模式,MSB,极性方式00,1/16系统时钟速率
; SPCR = 0x51; //不使用SPI中断,其它同上
ldi R24,81
out 0xd,R24
.dbline 42
; SPSR = 0x00; //setup SPI
clr R2
out 0xe,R2
.dbline 44
;
; temp = SPSR; //!!!
in R16,0xe
.dbline 45
; temp = SPDR; //清空SPI,和中断标志,使SPI空闲
in R16,0xf
.dbline -2
.dbline 46
; }
L3:
.dbline 0 ; func end
ret
.dbsym r temp 16 c
.dbend
.dbfunc e init_devices _init_devices fV
.even
_init_devices::
.dbline -1
.dbline 53
;
;
;
;
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
.dbline 55
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 56
; port_init1();
rcall _port_init1
.dbline 58
; // spi_init();
; uart_init();
rcall _uart_init
.dbline 63
;
; // MCUCR = 0x0c;
; //GICR|= 0x80;//enable INT1 interrupt
;
; GIFR = 0xc0;// 清除INT0、INT1 中断标志位
ldi R24,192
out 0x3a,R24
.dbline 64
; SEI(); //re-enable interrupts
sei
.dbline -2
.dbline 66
; //all peripherals are now initialized
; }
L4:
.dbline 0 ; func end
ret
.dbend
.dbfunc e init_devices2 _init_devices2 fV
.even
_init_devices2::
.dbline -1
.dbline 69
;
; void init_devices2(void)
; {
.dbline 71
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 72
; port_init2();
rcall _port_init2
.dbline 73
; spi_init();
rcall _spi_init
.dbline 79
; //uart_init();
;
; //MCUCR = 0x00;
; //GICR = 0x00;
;
; SEI(); //re-enable interrupts
sei
.dbline -2
.dbline 81
; //all peripherals are now initialized
; }
L5:
.dbline 0 ; func end
ret
.dbend
.dbfunc e port_init3 _port_init3 fV
.even
_port_init3::
.dbline -1
.dbline 84
;
; void port_init3(void)
; {
.dbline 85
; PORTB = 0x00;
clr R2
out 0x18,R2
.dbline 86
; DDRB = 0x00;
out 0x17,R2
.dbline 89
; //PORTB = 0xD7;
; // DDRB = 0x2C;
; PORTC = 0x00; //m103 output only
out 0x15,R2
.dbline 90
; DDRC = 0x00;
out 0x14,R2
.dbline 91
; PORTD = 0x00;
out 0x12,R2
.dbline 92
; DDRD = 0x20;
ldi R24,32
out 0x11,R24
.dbline -2
.dbline 93
; }
L6:
.dbline 0 ; func end
ret
.dbend
.dbfunc e main _main fV
; string -> <dead>
; i -> R20,R21
.even
_main::
.dbline -1
.dbline 96
;
; void main(void)
; {
.dbline 99
; uchar *string;
; int i;
; init_devices();
rcall _init_devices
.dbline 100
; SystemIni();
rcall _SystemIni
.dbline 101
; puts_hh("test start!");
ldi R16,<L8
ldi R17,>L8
rcall _puts_hh
.dbline 102
; init_devices2();
rcall _init_devices2
rjmp L10
L9:
.dbline 117
.dbline 119
ldi R16,150
ldi R17,0
rcall _delay_10ms
.dbline 120
rcall _init_devices
.dbline 121
rcall _ad_convert
.dbline 122
rcall _init_devices2
.dbline 123
rcall _Read_nrf905Add
.dbline 124
rcall _nrf905_Init
.dbline 125
rcall _RfSendProc
.dbline 126
lds R18,_Tx_Buf
clr R19
ldi R16,<L12
ldi R17,>L12
rcall _printf
.dbline 127
lds R18,_Tx_Buf+1
clr R19
ldi R16,<L13
ldi R17,>L13
rcall _printf
.dbline 128
lds R2,_Tx_Buf+3
clr R3
mov R3,R2
clr R2
lds R20,_Tx_Buf+2
clr R21
add R20,R2
adc R21,R3
.dbline 129
movw R18,R20
ldi R16,<L17
ldi R17,>L17
rcall _printf
.dbline 130
lds R2,_Tx_Buf+5
clr R3
mov R3,R2
clr R2
lds R20,_Tx_Buf+4
clr R21
add R20,R2
adc R21,R3
.dbline 131
movw R18,R20
ldi R16,<L20
ldi R17,>L20
rcall _printf
.dbline 133
L10:
.dbline 117
rjmp L9
X0:
.dbline -2
.dbline 136
; /*
; // spi_init();
; port_init3();
; //nrf905_Init();
; nrf905_Off();//断开电源
;
; ACSR=0x80; //别忘了关掉模拟比较器的电源哦
; MCUCR=(0<<SM2)|(1<<SM1)|(1<<SM0);//0 1 1 省电模式
; MCUCR|=(1<<SE);//仅在SLEEP 指令的前一条指令置位SE
; while(1){
; asm( "sleep" );}
; //*/
;
; //*
; while(1) {
;
; delay_10ms(150);
; init_devices();
; ad_convert();//开始AD转换
; init_devices2();
; Read_nrf905Add();//读取nrf905的接受和发送地址
; nrf905_Init();
; RfSendProc();//发送数据
; printf("slave add is %d\r\n",Tx_Buf[0]);
; printf("command is %x\r\n",Tx_Buf[1]);
; i=Tx_Buf[2]+(Tx_Buf[3]<<8);
; printf("temperlature is %d\r\n",i);
; i=Tx_Buf[4]+(Tx_Buf[5]<<8);
; printf("vcc is %d\r\n",i);
;
; }
; //*/
;
; }
L7:
.dbline 0 ; func end
ret
.dbsym l string 1 pc
.dbsym r i 20 I
.dbend
.dbfunc e SystemIni _SystemIni fV
.even
_SystemIni::
.dbline -1
.dbline 140
;
;
; void SystemIni()
; {
.dbline 141
; delay_10ms(20);
ldi R16,20
ldi R17,0
.dbline -2
.dbline 142
; }
L21:
.dbline 0 ; func end
rjmp _delay_10ms
.dbend
.area data(ram, con, rel)
.dbfile E:\公司用\atmega8l\final\nrf905_send1\main.c
L20:
.blkb 12
.area idata
.byte 'v,'c,'c,32,'i,'s,32,37,'d,13,10,0
.area data(ram, con, rel)
.dbfile E:\公司用\atmega8l\final\nrf905_send1\main.c
L17:
.blkb 21
.area idata
.byte 't,'e,'m,'p,'e,'r,'l,'a,'t,'u,'r,'e,32,'i,'s,32
.byte 37,'d,13,10,0
.area data(ram, con, rel)
.dbfile E:\公司用\atmega8l\final\nrf905_send1\main.c
L13:
.blkb 16
.area idata
.byte 'c,'o,'m,'m,'a,'n,'d,32,'i,'s,32,37,'x,13,10,0
.area data(ram, con, rel)
.dbfile E:\公司用\atmega8l\final\nrf905_send1\main.c
L12:
.blkb 18
.area idata
.byte 's,'l,'a,'v,'e,32,'a,'d,'d,32,'i,'s,32,37,'d,13
.byte 10,0
.area data(ram, con, rel)
.dbfile E:\公司用\atmega8l\final\nrf905_send1\main.c
L8:
.blkb 12
.area idata
.byte 't,'e,'s,'t,32,'s,'t,'a,'r,'t,33,0
.area data(ram, con, rel)
.dbfile E:\公司用\atmega8l\final\nrf905_send1\main.c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -