📄 init.s
字号:
.module init.c
.area data(ram, con, rel)
_flag::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile E:\ICCAVR\project\AVRMEG~3\icc\019-BOOT\init.c
.dbsym e flag _flag c
.area text(rom, con, rel)
.dbfile E:\ICCAVR\project\AVRMEG~3\icc\019-BOOT\init.c
.dbfunc e io_init _io_init fV
.even
_io_init::
.dbline -1
.dbline 18
; #include "init.h"
;
; /*参数声明*/
; unsigned char msg_buffer[300]; //消息体
; unsigned char seqNumber; //顺序数
; unsigned char checkSum; //和校验
; unsigned char clockSpeed; //时钟速度
; unsigned char resetPolarity; //复位极性
; unsigned char paramControllerInit; //参数控制器初始化
; unsigned char prgMode; //编程模式
; unsigned char statusMachine; //状态机
; unsigned int msgSize; //消息尺寸
; unsigned char flag = 0; //接收到消息
;
; unsigned long address; //地址
;
; /*IO口初始化函数*/
; void io_init(void) {
.dbline 20
;
; DDRA = 0x00; /*方向输入*/
clr R2
out 0x1a,R2
.dbline 21
; PORTA = 0xFF; /*打开上拉*/
ldi R24,255
out 0x1b,R24
.dbline 22
; DDRB = 0x00; /*方向输出*/
out 0x17,R2
.dbline 23
; PORTB = 0xFF; /*输出高电平*/
out 0x18,R24
.dbline 24
; DDRC = 0x00; /*不用的IO口建议设置为输入带上拉*/
out 0x14,R2
.dbline 25
; PORTC = 0xFF;
out 0x15,R24
.dbline 26
; DDRD = 0x00;
out 0x11,R2
.dbline 27
; PORTD = 0xFF;
out 0x12,R24
.dbline 28
; DDRE = 0x00;
out 0x2,R2
.dbline 29
; PORTE = 0xFF;
out 0x3,R24
.dbline 30
; DDRF = 0x00;
sts 97,R2
.dbline 31
; PORTF = 0xFF;
sts 98,R24
.dbline 32
; DDRG = 0x00;
sts 100,R2
.dbline 33
; PORTG = 0xFF;
sts 101,R24
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e timer1_init _timer1_init fV
.even
_timer1_init::
.dbline -1
.dbline 36
; }
;
; void timer1_init(void) {
.dbline 37
; TCCR1B = 0x00;
clr R2
out 0x2e,R2
.dbline 38
; TCNT1H = 0x00;
out 0x2d,R2
.dbline 39
; TCNT1L = 0x00;
out 0x2c,R2
.dbline 40
; TCCR1A = 0x00;
out 0x2f,R2
.dbline 41
; TCCR1B = 0x05;
ldi R24,5
out 0x2e,R24
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.dbfunc e init _init fV
.even
_init::
.dbline -1
.dbline 43
; }
; void init(void) {
.dbline 45
;
; CLI(); /*关闭中断源 */
cli
.dbline 46
; statusMachine = ST_START; /*变量初始化*/
ldi R24,240
sts _statusMachine,R24
.dbline 47
; paramControllerInit=0x00;
clr R2
sts _paramControllerInit,R2
.dbline 48
; prgMode=0;
sts _prgMode,R2
.dbline 50
;
; io_init();
xcall _io_init
.dbline 58
;
; /*入口判断*/
; /*
; 在执行强行跳转指令"jmp 0x0000"前,对寄存器MCUCR的操作是将中断向量地址
; 迁移回应用程序区的头部,因为在ICCAVR环境中编译Bootloader程序时,其自动
; 把中断向量地址迁移到了Bootloader区的头部。
; */
; if (PINE & (1 << PE7)) { /*判断按键是否按下*/
sbis 0x1,7
rjmp L4
.dbline 58
.dbline 59
; MCUCR = 0x01;
ldi R24,1
out 0x35,R24
.dbline 60
; MCUCR = 0x00; /*将中断向量表迁移到应用程序区头部*/
clr R2
out 0x35,R2
.dbline 61
; RAMPZ = 0x00; /*RAMPZ清零初始化*/
out 0x3b,R2
.dbline 62
; asm("jmp 0x000000\n");; /*进入应用程序区*/
jmp 0x000000
.dbline 62
.dbline 63
; }
L4:
.dbline 65
;
; DDRB = 0xFF;
ldi R24,255
out 0x17,R24
.dbline 66
; uart0_init(); /*串口初始化函数*/
xcall _uart0_init
.dbline 67
; timer1_init(); /*定时器T初始化*/
xcall _timer1_init
.dbline -2
L3:
.dbline 0 ; func end
ret
.dbend
.area bss(ram, con, rel)
.dbfile E:\ICCAVR\project\AVRMEG~3\icc\019-BOOT\init.c
_address::
.blkb 4
.dbsym e address _address l
_msgSize::
.blkb 2
.dbsym e msgSize _msgSize i
_statusMachine::
.blkb 1
.dbsym e statusMachine _statusMachine c
_prgMode::
.blkb 1
.dbsym e prgMode _prgMode c
_paramControllerInit::
.blkb 1
.dbsym e paramControllerInit _paramControllerInit c
_resetPolarity::
.blkb 1
.dbsym e resetPolarity _resetPolarity c
_clockSpeed::
.blkb 1
.dbsym e clockSpeed _clockSpeed c
_checkSum::
.blkb 1
.dbsym e checkSum _checkSum c
_seqNumber::
.blkb 1
.dbsym e seqNumber _seqNumber c
_msg_buffer::
.blkb 300
.dbsym e msg_buffer _msg_buffer A[300:300]c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -