?? test.s
字號:
.module test.c
.area data(ram, con, rel)
_data::
.blkb 1
.area idata
.byte 1
.area data(ram, con, rel)
.dbfile F:\工程文件\AVR光盤\例程\m16\步進(jìn)測試\test.c
.dbsym e data _data c
.area text(rom, con, rel)
.dbfile F:\工程文件\AVR光盤\例程\m16\步進(jìn)測試\test.c
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 10
; //ICC-AVR application builder : 2007-8-2 13:09:26
; // Target : M16
; // Crystal: 8.0000Mhz
;
; #include <iom16v.h>
; #include <macros.h>
;
; unsigned char data = 0x1;
; void port_init(void)
; {
.dbline 11
; PORTA = 0x00;
clr R2
out 0x1b,R2
.dbline 12
; DDRA = 0x00;
out 0x1a,R2
.dbline 13
; PORTB = 0xFF;
ldi R24,255
out 0x18,R24
.dbline 14
; DDRB = 0xFF;
out 0x17,R24
.dbline 15
; PORTC = 0x00; //m103 output only
out 0x15,R2
.dbline 16
; DDRC = 0x00;
out 0x14,R2
.dbline 17
; PORTD = 0x00;
out 0x12,R2
.dbline 18
; DDRD = 0x00;
out 0x11,R2
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e timer1_init _timer1_init fV
.even
_timer1_init::
.dbline -1
.dbline 26
; }
;
; //TIMER1 initialize - prescale:64
; // WGM: 0) Normal, TOP=0xFFFF
; // desired value: 200mSec
; // actual value: 200.000mSec (0.0%)
; void timer1_init(void)
; {
.dbline 27
; TCCR1B = 0x00; //stop
clr R2
out 0x2e,R2
.dbline 28
; TCNT1H = 0xef; //setup
ldi R24,239
out 0x2d,R24
.dbline 29
; TCNT1L = 0x58;
ldi R24,88
out 0x2c,R24
.dbline 30
; OCR1AH = 0x61;
ldi R24,97
out 0x2b,R24
.dbline 31
; OCR1AL = 0xA8;
ldi R24,168
out 0x2a,R24
.dbline 32
; OCR1BH = 0x61;
ldi R24,97
out 0x29,R24
.dbline 33
; OCR1BL = 0xA8;
ldi R24,168
out 0x28,R24
.dbline 34
; ICR1H = 0x61;
ldi R24,97
out 0x27,R24
.dbline 35
ldi R24,168
out 0x26,R24
.dbline 36
; TCCR1A = 0x00;
out 0x2f,R2
.dbline 37
; TCCR1B = 0x03; //start Timer
ldi R24,3
out 0x2e,R24
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 32
jmp _timer1_ovf_isr
.area text(rom, con, rel)
.dbfile F:\工程文件\AVR光盤\例程\m16\步進(jìn)測試\test.c
.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
.even
_timer1_ovf_isr::
st -y,R2
st -y,R24
in R2,0x3f
st -y,R2
.dbline -1
.dbline 42
; }
;
; #pragma interrupt_handler timer1_ovf_isr:9
; void timer1_ovf_isr(void)
; {
.dbline 44
; //TIMER1 has overflowed
; TCNT1H = 0xef; //reload counter high value
ldi R24,239
out 0x2d,R24
.dbline 45
; TCNT1L = 0x58; //reload counter low value
ldi R24,88
out 0x2c,R24
.dbline 46
; if(data == 0x01)
lds R24,_data
cpi R24,1
brne L4
.dbline 47
; data = 0;
clr R2
sts _data,R2
xjmp L5
L4:
.dbline 49
; else
; data = 1;
ldi R24,1
sts _data,R24
L5:
.dbline 50
; PORTB = data;
lds R2,_data
out 0x18,R2
.dbline -2
L3:
ld R2,y+
out 0x3f,R2
ld R24,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
.dbfunc e init_devices _init_devices fV
.even
_init_devices::
.dbline -1
.dbline 55
; }
;
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
.dbline 57
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 58
; port_init();
xcall _port_init
.dbline 59
; timer1_init();
xcall _timer1_init
.dbline 61
;
; MCUCR = 0x00;
clr R2
out 0x35,R2
.dbline 62
; GICR = 0x00;
out 0x3b,R2
.dbline 63
; TIMSK = 0x04; //timer interrupt sources
ldi R24,4
out 0x39,R24
.dbline 64
; SEI(); //re-enable interrupts
sei
.dbline -2
L6:
.dbline 0 ; func end
ret
.dbend
.dbfunc e main _main fV
.even
_main::
.dbline -1
.dbline 70
; //all peripherals are now initialized
; }
;
; //
; void main(void)
; {
.dbline 71
; init_devices();
xcall _init_devices
.dbline -2
L7:
.dbline 0 ; func end
ret
.dbend
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -