📄 main_18b20.s
字号:
.module main_18b20.c
.area text(rom, con, rel)
.dbfile F:\try\DS18B20\main_18b20.c
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 10
; //ICC-AVR application builder : 2008-4-7 PM 04:31:51
; // Target : M16
; // Crystal: 8.0000Mhz
;
; #include <iom16v.h>
; #include <macros.h>
; #include "DS18B20.h"
;
; void port_init(void)
; {
.dbline 11
; PORTA = 0x00;
clr R2
out 0x1b,R2
.dbline 12
; DDRA = 0x00;
out 0x1a,R2
.dbline 13
; PORTB = 0x00;
out 0x18,R2
.dbline 14
; DDRB = 0x00;
out 0x17,R2
.dbline 15
; PORTC = 0x00; //m103 output only
out 0x15,R2
.dbline 16
; DDRC = 0xFF;
ldi R24,255
out 0x14,R24
.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 timer0_init _timer0_init fV
.even
_timer0_init::
.dbline -1
.dbline 26
; }
;
; //TIMER0 initialize - prescale:1024
; // WGM: Normal
; // desired value: 25mSec
; // actual value: 24.960mSec (0.2%)
; void timer0_init(void)
; {
.dbline 27
; TCCR0 = 0x00; //stop
clr R2
out 0x33,R2
.dbline 28
; TCNT0 = 0x3D; //set count
ldi R24,61
out 0x32,R24
.dbline 29
; OCR0 = 0xC3; //set compare
ldi R24,195
out 0x3c,R24
.dbline 30
; TCCR0 = 0x05; //start timer
ldi R24,5
out 0x33,R24
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 36
jmp _timer0_ovf_isr
.area text(rom, con, rel)
.dbfile F:\try\DS18B20\main_18b20.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 35
; }
;
; #pragma interrupt_handler timer0_ovf_isr:iv_TIM0_OVF
; void timer0_ovf_isr(void)
; {
.dbline 36
; TCNT0 = 0x3D; //reload counter value
ldi R24,61
out 0x32,R24
.dbline -2
L3:
.dbline 0 ; func end
ld R24,y+
out 0x3f,R24
ld R24,y+
reti
.dbend
.dbfunc e uart0_init _uart0_init fV
.even
_uart0_init::
.dbline -1
.dbline 43
; }
;
; //UART0 initialize
; // desired baud rate: 9600
; // actual: baud rate:9615 (0.2%)
; void uart0_init(void)
; {
.dbline 44
; UCSRB = 0x00; //disable while setting baud rate
clr R2
out 0xa,R2
.dbline 45
; UCSRA = 0x00;
out 0xb,R2
.dbline 46
; UCSRC = BIT(URSEL) | 0x06;
ldi R24,134
out 0x20,R24
.dbline 47
; UBRRL = 0x33; //set baud rate lo
ldi R24,51
out 0x9,R24
.dbline 48
; UBRRH = 0x00; //set baud rate hi
out 0x20,R2
.dbline 49
; UCSRB = 0x98;
ldi R24,152
out 0xa,R24
.dbline -2
L4:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 44
jmp _uart0_rx_isr
.area text(rom, con, rel)
.dbfile F:\try\DS18B20\main_18b20.c
.dbfunc e uart0_rx_isr _uart0_rx_isr fV
.even
_uart0_rx_isr::
.dbline -1
.dbline 54
; }
;
; #pragma interrupt_handler uart0_rx_isr:iv_USART0_RXC
; void uart0_rx_isr(void)
; {
.dbline -2
L5:
.dbline 0 ; func end
reti
.dbend
.dbfunc e init_devices _init_devices fV
.even
_init_devices::
.dbline -1
.dbline 60
; //uart has received a character in UDR
; }
;
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
.dbline 62
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 63
; port_init();
xcall _port_init
.dbline 64
; timer0_init();
xcall _timer0_init
.dbline 65
; uart0_init();
xcall _uart0_init
.dbline 67
;
; MCUCR = 0x00;
clr R2
out 0x35,R2
.dbline 68
; GICR = 0x00;
out 0x3b,R2
.dbline 69
; TIMSK = 0x01; //timer interrupt sources
ldi R24,1
out 0x39,R24
.dbline 70
; SEI(); //re-enable interrupts
sei
.dbline -2
L6:
.dbline 0 ; func end
ret
.dbend
.dbfunc e putchar _putchar fV
; TmpCh -> R16
.even
_putchar::
.dbline -1
.dbline 76
; //all peripherals are now initialized
; }
;
; //输出一个字符
; void putchar(unsigned char TmpCh)
; {
L8:
.dbline 77
; while( !(UCSRA & (1<<UDRE)) );
L9:
.dbline 77
sbis 0xb,5
rjmp L8
X0:
.dbline 78
; UDR = TmpCh;
out 0xc,R16
.dbline -2
L7:
.dbline 0 ; func end
ret
.dbsym r TmpCh 16 c
.dbend
.dbfunc e main _main fV
; tempout -> R10
.even
_main::
.dbline -1
.dbline 82
; }
;
; void main(void)
; {
.dbline 83
; unsigned char tempout = 0;
clr R10
.dbline 84
; init_devices();
xcall _init_devices
.dbline 85
; init_1820();
xcall _init_1820
.dbline 86
; putchar(0xFF);
ldi R16,255
xcall _putchar
.dbline 87
; delay_nms(200);
ldi R16,200
ldi R17,0
xcall _delay_nms
.dbline 88
; ;
xjmp L13
L12:
.dbline 90
; while(1)
; {
.dbline 91
; tempout = gettemp();
xcall _gettemp
mov R10,R16
.dbline 92
; delay_nms(30);
ldi R16,30
ldi R17,0
xcall _delay_nms
.dbline 93
; putchar(tempout);
mov R16,R10
xcall _putchar
.dbline 95
; //putchar(wml);
; delay_nms(3000);
ldi R16,3000
ldi R17,11
xcall _delay_nms
.dbline 96
; };
L13:
.dbline 89
xjmp L12
X1:
.dbline -2
L11:
.dbline 0 ; func end
ret
.dbsym r tempout 10 c
.dbend
; };
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -