?? uartserver.s
字號:
.module uartserver.c
.area data(ram, con, rel)
_flag::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile F:\單片機教學\調試程序\實驗二舵機串口\uartserver.c
.dbsym e flag _flag c
.area text(rom, con, rel)
.dbfile F:\單片機教學\調試程序\實驗二舵機串口\uartserver.c
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 12
; //ICC-AVR application builder : 2005-3-8 下午 09:54:40
; // Target : M8
; // Crystal: 11.059Mhz
;
;
; #include <iom8v.h>
; #include <macros.h>
; char data;
; char flag=0;
;
; void port_init(void)
; {
.dbline 13
; PORTB = 0xFF;
ldi R24,255
out 0x18,R24
.dbline 14
; DDRB = 0x02;
ldi R24,2
out 0x17,R24
.dbline 15
; PORTC = 0x7F; //m103 output only
ldi R24,127
out 0x15,R24
.dbline 16
; DDRC = 0x00;
clr R2
out 0x14,R2
.dbline 17
; PORTD = 0xFF;
ldi R24,255
out 0x12,R24
.dbline 18
; DDRD = 0x00;
out 0x11,R2
.dbline -2
.dbline 19
; }
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e timer1_init _timer1_init fV
.even
_timer1_init::
.dbline -1
.dbline 25
; //TIMER1 initialisation - prescale:8
; // WGM: 14) PWM fast, TOP=ICRn
; // desired value: 50Hz
; // actual value: 50.001Hz (0.0%)
; void timer1_init(void)
; {
.dbline 26
; TCCR1B = 0x00; //stop
clr R2
out 0x2e,R2
.dbline 28
;
; TCNT1H = 0x00; //setup
out 0x2d,R2
.dbline 29
; TCNT1L = 0x00;
out 0x2c,R2
.dbline 31
;
; OCR1AH = 0x08;
ldi R24,8
out 0x2b,R24
.dbline 32
; OCR1AL = 0x19;
ldi R24,25
out 0x2a,R24
.dbline 33
; OCR1BH = 0x08;
ldi R24,8
out 0x29,R24
.dbline 34
; OCR1BL = 0x19;
ldi R24,25
out 0x28,R24
.dbline 36
;
; ICR1H = 0x6B;
ldi R24,107
out 0x27,R24
.dbline 37
; ICR1L = 0xFE;
ldi R24,254
out 0x26,R24
.dbline 39
;
; TCCR1A = 0xA2;
ldi R24,162
out 0x2f,R24
.dbline 40
; TCCR1B = 0x1A; //start Timer
ldi R24,26
out 0x2e,R24
.dbline -2
.dbline 41
; }
L2:
.dbline 0 ; func end
ret
.dbend
.dbfunc e uart0_init _uart0_init fV
.even
_uart0_init::
.dbline -1
.dbline 48
; //UART0 initialisation
; // desired baud rate: 9600
; // actual: baud rate:9600 (0.0%)
; // char size: 8 bit
; // parity: Disabled
; void uart0_init(void)
; {
.dbline 49
; UCSRB = 0x00; //disable while setting baud rate
clr R2
out 0xa,R2
.dbline 50
; UCSRA = 0x00;
out 0xb,R2
.dbline 51
; UCSRC = 0x86;
ldi R24,134
out 0x20,R24
.dbline 52
; UBRRL = 0x47; //set baud rate lo
ldi R24,71
out 0x9,R24
.dbline 53
; UBRRH = 0x00; //set baud rate hi
out 0x20,R2
.dbline 54
; UCSRB = 0x98;
ldi R24,152
out 0xa,R24
.dbline -2
.dbline 55
; }
L3:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 22
rjmp _uart0_rx_isr
.area text(rom, con, rel)
.dbfile F:\單片機教學\調試程序\實驗二舵機串口\uartserver.c
.dbfunc e uart0_rx_isr _uart0_rx_isr fV
.even
_uart0_rx_isr::
st -y,R2
st -y,R24
in R2,0x3f
st -y,R2
.dbline -1
.dbline 59
;
; #pragma interrupt_handler uart0_rx_isr:12
; void uart0_rx_isr(void)
; {
.dbline 62
; //uart has received a character in UDR
;
; data = UDR;
in R2,0xc
sts _data,R2
.dbline 63
; UDR = data;
out 0xc,R2
.dbline 64
; flag = 1;
ldi R24,1
sts _flag,R24
.dbline -2
.dbline 65
; }
L4:
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 69
;
; //call this routine to initialise all peripherals
; void init_devices(void)
; {
.dbline 71
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 72
; port_init();
rcall _port_init
.dbline 73
; timer1_init();
rcall _timer1_init
.dbline 74
; uart0_init();
rcall _uart0_init
.dbline 76
;
; MCUCR = 0x00;
clr R2
out 0x35,R2
.dbline 77
; GICR = 0x00;
out 0x3b,R2
.dbline 78
; TIMSK = 0x00; //timer interrupt sources
out 0x39,R2
.dbline 79
; SEI(); //re-enable interrupts
sei
.dbline -2
.dbline 81
; //all peripherals are now initialised
; }
L5:
.dbline 0 ; func end
ret
.dbend
.dbfunc e main _main fV
; time -> R20,R21
.even
_main::
.dbline -1
.dbline 85
;
; //
; void main(void)
; {
.dbline 87
; unsigned int time;
; init_devices();
rcall _init_devices
rjmp L8
L7:
.dbline 90
; //insert your functional code here...
; while(1)
; {
.dbline 91
; if(flag == 1)
lds R24,_flag
cpi R24,1
brne L10
.dbline 92
; {
.dbline 93
; time = data *31;
lds R2,_data
ldi R24,31
mul R24,R2
movw R20,R0
.dbline 94
; time = (time>>1)+691;
lsr R21
ror R20
subi R20,77 ; offset = 691
sbci R21,253
.dbline 95
; OCR1AH = time >>8;
movw R2,R20
mov R2,R3
clr R3
out 0x2b,R2
.dbline 96
; OCR1AL = time;
out 0x2a,R20
.dbline 97
; flag = 0;
clr R2
sts _flag,R2
.dbline 98
; }
L10:
.dbline 99
L8:
.dbline 89
rjmp L7
X0:
.dbline -2
.dbline 100
; }
; }
L6:
.dbline 0 ; func end
ret
.dbsym r time 20 i
.dbend
.area bss(ram, con, rel)
.dbfile F:\單片機教學\調試程序\實驗二舵機串口\uartserver.c
_data::
.blkb 1
.dbsym e data _data c
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -