📄 main.s
字号:
.module main.c
.area text(rom, con, rel)
.dbfile D:\AVR\Mega32_160X64Lcd\main.c
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 10
; //ICC-AVR application builder : 2006-12-29 13:02:24
; // Target : M32
; // Crystal: 7.3728Mhz
;
; #include "define.h"
;
; extern void Init_Lcd(void) ;
;
; void port_init(void)
; {
.dbline 11
; PORTA = 0x00;
clr R2
out 0x1b,R2
.dbline 12
; DDRA = 0xFF;
ldi R24,255
out 0x1a,R24
.dbline 13
; PORTB = 0x07;
ldi R24,7
out 0x18,R24
.dbline 14
; DDRB = 0xF8;
ldi R24,248
out 0x17,R24
.dbline 15
; PORTC = 0xFF;
ldi R24,255
out 0x15,R24
.dbline 16
; DDRC = 0x00;
out 0x14,R2
.dbline 17
; PORTD = 0x7F;
ldi R24,127
out 0x12,R24
.dbline 18
; DDRD = 0x80;
ldi R24,128
out 0x11,R24
.dbline -2
.dbline 19
; }
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e watchdog_init _watchdog_init fV
.even
_watchdog_init::
.dbline -1
.dbline 24
;
; //Watchdog initialisation
; // prescale: 2048K cycles
; void watchdog_init(void)
; {
.dbline 25
; WDR(); //this prevents a timout on enabling
wdr
.dbline 26
; WDTCR = 0x0F; //WATCHDOG ENABLED - dont forget to issue WDRs
ldi R24,15
out 0x21,R24
.dbline -2
.dbline 27
; }
L2:
.dbline 0 ; func end
ret
.dbend
.dbfunc e timer0_init _timer0_init fV
.even
_timer0_init::
.dbline -1
.dbline 34
;
; //TIMER0 initialisation - prescale:1024
; // WGM: Normal
; // desired value: 100Hz
; // actual value: 101.408Hz (1.4%)
; void timer0_init(void)
; {
.dbline 35
; TCCR0 = 0x00; //stop
clr R2
out 0x33,R2
.dbline 36
; TCNT0 = 0xB9; //set count
ldi R24,185
out 0x32,R24
.dbline 37
; OCR0 = 0x47; //set compare
ldi R24,71
out 0x3c,R24
.dbline 38
; TCCR0 = 0x05; //start timer
ldi R24,5
out 0x33,R24
.dbline -2
.dbline 39
; }
L3:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 44
jmp _timer0_ovf_isr
.area text(rom, con, rel)
.dbfile D:\AVR\Mega32_160X64Lcd\main.c
.dbfunc e timer0_ovf_isr _timer0_ovf_isr fV
.even
_timer0_ovf_isr::
st -y,R24
in R24,0x3f
st -y,R24
.dbline -1
.dbline 43
;
; #pragma interrupt_handler timer0_ovf_isr:12
; void timer0_ovf_isr(void)
; {
.dbline 44
; TCNT0 = 0xB9; //reload counter value
ldi R24,185
out 0x32,R24
.dbline -2
.dbline 45
; }
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 53
;
; //UART0 initialisation
; // desired baud rate: 38400
; // actual: baud rate:38400 (0.0%)
; // char size: 8 bit
; // parity: Disabled
; void uart0_init(void)
; {
.dbline 54
; UCSRB = 0x00; //disable while setting baud rate
clr R2
out 0xa,R2
.dbline 55
; UCSRA = 0x00;
out 0xb,R2
.dbline 56
; UCSRC = 0x06;
ldi R24,6
out 0x20,R24
.dbline 57
; UBRRL = 0x0B; //set baud rate lo
ldi R24,11
out 0x9,R24
.dbline 58
; UBRRH = 0x00; //set baud rate hi
out 0x20,R2
.dbline 59
; UCSRB = 0xB0;
ldi R24,176
out 0xa,R24
.dbline -2
.dbline 60
; }
L5:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 52
jmp _uart0_rx_isr
.area text(rom, con, rel)
.dbfile D:\AVR\Mega32_160X64Lcd\main.c
.dbfunc e uart0_rx_isr _uart0_rx_isr fV
.even
_uart0_rx_isr::
.dbline -1
.dbline 64
;
; #pragma interrupt_handler uart0_rx_isr:14
; void uart0_rx_isr(void)
; {
.dbline -2
.dbline 66
; //uart has received a character in UDR
; }
L6:
.dbline 0 ; func end
reti
.dbend
.area vector(rom, abs)
.org 56
jmp _uart0_udre_isr
.area text(rom, con, rel)
.dbfile D:\AVR\Mega32_160X64Lcd\main.c
.dbfunc e uart0_udre_isr _uart0_udre_isr fV
.even
_uart0_udre_isr::
.dbline -1
.dbline 69
; #pragma interrupt_handler uart0_udre_isr:15
; void uart0_udre_isr(void)
; {
.dbline -2
.dbline 71
; //character transferred to shift register so UDR is now empty
; }
L7:
.dbline 0 ; func end
reti
.dbend
.area vector(rom, abs)
.org 8
jmp _int1_isr
.area text(rom, con, rel)
.dbfile D:\AVR\Mega32_160X64Lcd\main.c
.dbfunc e int1_isr _int1_isr fV
.even
_int1_isr::
.dbline -1
.dbline 75
;
; #pragma interrupt_handler int1_isr:3
; void int1_isr(void)
; {
.dbline -2
.dbline 77
; //external interupt on INT1
; }
L8:
.dbline 0 ; func end
reti
.dbend
.dbfunc e init_devices _init_devices fV
.even
_init_devices::
.dbline -1
.dbline 81
;
; //call this routine to initialise all peripherals
; void init_devices(void)
; {
.dbline 83
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 84
; port_init();
xcall _port_init
.dbline 85
; watchdog_init();
xcall _watchdog_init
.dbline 86
; timer0_init();
xcall _timer0_init
.dbline 87
; uart0_init();
xcall _uart0_init
.dbline 89
;
; MCUCR = 0x08;
ldi R24,8
out 0x35,R24
.dbline 90
; GICR = 0x80;
ldi R24,128
out 0x3b,R24
.dbline 91
; TIMSK = 0x01; //timer interrupt sources
ldi R24,1
out 0x39,R24
.dbline 92
; SEI(); //re-enable interrupts
sei
.dbline -2
.dbline 94
; //all peripherals are now initialised
; }
L9:
.dbline 0 ; func end
ret
.dbend
.dbfunc e main _main fV
.even
_main::
.dbline -1
.dbline 97
;
; void main(void)
; {
.dbline 98
; init_devices();
xcall _init_devices
.dbline 99
; Init_Lcd();
.dbline -2
.dbline 100
; }
L10:
.dbline 0 ; func end
xjmp _Init_Lcd
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -