📄 init.s
字号:
.module init.C
.area text(rom, con, rel)
.dbfile D:\xb_work\标准速度测试仪\speed_mega8\init.C
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 9
; //ICC-AVR application builder : 2006-10-11 上午 11:14:38
; // Target : M8
; // Crystal: 6.0000Mhz
;
; #include <iom8v.h>
; #include <macros.h>
;
; void port_init(void)
; {
.dbline 10
; PORTB = 0x00;
clr R2
out 0x18,R2
.dbline 11
; DDRB = 0x00;
out 0x17,R2
.dbline 12
; PORTC = 0x00; //m103 output only
out 0x15,R2
.dbline 13
; DDRC = 0x00;
out 0x14,R2
.dbline 14
; PORTD = 0x00;
out 0x12,R2
.dbline 15
; DDRD = 0x00;
out 0x11,R2
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e watchdog_init _watchdog_init fV
.even
_watchdog_init::
.dbline -1
.dbline 21
; }
;
; //Watchdog initialize
; // prescale: 16K
; void watchdog_init(void)
; {
.dbline 22
; WDR(); //this prevents a timout on enabling
wdr
.dbline 23
; WDTCR = 0x08; //WATCHDOG ENABLED - dont forget to issue WDRs
ldi R24,8
out 0x21,R24
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.dbfunc e timer1_init _timer1_init fV
.even
_timer1_init::
.dbline -1
.dbline 31
; }
;
; //TIMER1 initialize - prescale:1
; // WGM: 0) Normal, TOP=0xFFFF
; // desired value: 320Hz
; // actual value: 320.000Hz (0.0%)
; void timer1_init(void)
; {
.dbline 32
; TCCR1B = 0x00; //stop
clr R2
out 0x2e,R2
.dbline 34
;
; TCNT1H = 0xB6; //setup
ldi R24,182
out 0x2d,R24
.dbline 35
; TCNT1L = 0xC2;
ldi R24,194
out 0x2c,R24
.dbline 37
;
; OCR1AH = 0x49;
ldi R24,73
out 0x2b,R24
.dbline 38
; OCR1AL = 0x3E;
ldi R24,62
out 0x2a,R24
.dbline 39
; OCR1BH = 0x49;
ldi R24,73
out 0x29,R24
.dbline 40
; OCR1BL = 0x3E;
ldi R24,62
out 0x28,R24
.dbline 41
; ICR1H = 0x49;
ldi R24,73
out 0x27,R24
.dbline 42
; ICR1L = 0x3E;
ldi R24,62
out 0x26,R24
.dbline 43
; TCCR1A = 0x00;
out 0x2f,R2
.dbline 45
;
; TCCR1B = 0x01; //start Timer
ldi R24,1
out 0x2e,R24
.dbline -2
L3:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 16
rjmp _timer1_ovf_isr
.area text(rom, con, rel)
.dbfile D:\xb_work\标准速度测试仪\speed_mega8\init.C
.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
.even
_timer1_ovf_isr::
st -y,R24
in R24,0x3f
st -y,R24
.dbline -1
.dbline 50
; }
;
; #pragma interrupt_handler timer1_ovf_isr:9
; void timer1_ovf_isr(void)
; {
.dbline 52
; //TIMER1 has overflowed
; TCNT1H = 0xB6; //reload counter high value
ldi R24,182
out 0x2d,R24
.dbline 53
; TCNT1L = 0xC2; //reload counter low value
ldi R24,194
out 0x2c,R24
.dbline -2
L4:
ld R24,y+
out 0x3f,R24
ld R24,y+
.dbline 0 ; func end
reti
.dbend
.dbfunc e uart0_init _uart0_init fV
.even
_uart0_init::
.dbline -1
.dbline 62
; }
;
; //UART0 initialize
; // desired baud rate: 9600
; // actual: baud rate:9615 (0.2%)
; // char size: 8 bit
; // parity: Disabled
; void uart0_init(void)
; {
.dbline 63
; UCSRB = 0x00; //disable while setting baud rate
clr R2
out 0xa,R2
.dbline 64
; UCSRA = 0x00;
out 0xb,R2
.dbline 65
; UCSRC = BIT(URSEL) | 0x06;
ldi R24,134
out 0x20,R24
.dbline 66
; UBRRL = 0x26; //set baud rate lo
ldi R24,38
out 0x9,R24
.dbline 67
; UBRRH = 0x00; //set baud rate hi
out 0x20,R2
.dbline 68
; UCSRB = 0xD8;
ldi R24,216
out 0xa,R24
.dbline -2
L5:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 22
rjmp _uart0_rx_isr
.area text(rom, con, rel)
.dbfile D:\xb_work\标准速度测试仪\speed_mega8\init.C
.dbfunc e uart0_rx_isr _uart0_rx_isr fV
.even
_uart0_rx_isr::
.dbline -1
.dbline 73
; }
;
; #pragma interrupt_handler uart0_rx_isr:12
; void uart0_rx_isr(void)
; {
.dbline -2
L6:
.dbline 0 ; func end
reti
.dbend
.area vector(rom, abs)
.org 26
rjmp _uart0_tx_isr
.area text(rom, con, rel)
.dbfile D:\xb_work\标准速度测试仪\speed_mega8\init.C
.dbfunc e uart0_tx_isr _uart0_tx_isr fV
.even
_uart0_tx_isr::
.dbline -1
.dbline 79
; //uart has received a character in UDR
; }
;
; #pragma interrupt_handler uart0_tx_isr:14
; void uart0_tx_isr(void)
; {
.dbline -2
L7:
.dbline 0 ; func end
reti
.dbend
.dbfunc e init_devices _init_devices fV
.even
_init_devices::
.dbline -1
.dbline 85
; //character has been transmitted
; }
;
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
.dbline 87
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 88
; port_init();
rcall _port_init
.dbline 89
; watchdog_init();
rcall _watchdog_init
.dbline 90
; timer1_init();
rcall _timer1_init
.dbline 91
; uart0_init();
rcall _uart0_init
.dbline 93
;
; MCUCR = 0x00;
clr R2
out 0x35,R2
.dbline 94
; GICR = 0x00;
out 0x3b,R2
.dbline 95
; TIMSK = 0x04; //timer interrupt sources
ldi R24,4
out 0x39,R24
.dbline 96
; SEI(); //re-enable interrupts
sei
.dbline -2
L8:
.dbline 0 ; func end
ret
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -