F:程序DS18B20.rar索读取温度

源代码在线查看: main_18b20.lis

软件大小: 88 K
上传用户: KuFly
关键词: DS 18 20
下载地址: 免注册下载 普通下载 VIP

相关代码

				                        .module main_18b20.c
				                        .area text(rom, con, rel)
				 0000                   .dbfile F:\try\DS18B20\main_18b20.c
				 0000                   .dbfunc e port_init _port_init fV
				                        .even
				 0000           _port_init::
				 0000                   .dbline -1
				 0000                   .dbline 10
				 0000           ; //ICC-AVR application builder : 2008-4-7 PM 04:31:51
				 0000           ; // Target : M16
				 0000           ; // Crystal: 8.0000Mhz
				 0000           ; 
				 0000           ; #include 
				 0000           ; #include 
				 0000           ; #include "DS18B20.h"
				 0000           ; 
				 0000           ; void port_init(void)
				 0000           ; {
				 0000                   .dbline 11
				 0000           ;  PORTA = 0x00;
				 0000 2224              clr R2
				 0002 2BBA              out 0x1b,R2
				 0004                   .dbline 12
				 0004           ;  DDRA  = 0x00;
				 0004 2ABA              out 0x1a,R2
				 0006                   .dbline 13
				 0006           ;  PORTB = 0x00;
				 0006 28BA              out 0x18,R2
				 0008                   .dbline 14
				 0008           ;  DDRB  = 0x00;
				 0008 27BA              out 0x17,R2
				 000A                   .dbline 15
				 000A           ;  PORTC = 0x00; //m103 output only
				 000A 25BA              out 0x15,R2
				 000C                   .dbline 16
				 000C           ;  DDRC  = 0xFF;
				 000C 8FEF              ldi R24,255
				 000E 84BB              out 0x14,R24
				 0010                   .dbline 17
				 0010           ;  PORTD = 0x00;
				 0010 22BA              out 0x12,R2
				 0012                   .dbline 18
				 0012           ;  DDRD  = 0x00;
				 0012 21BA              out 0x11,R2
				 0014                   .dbline -2
				 0014           L1:
				 0014                   .dbline 0 ; func end
				 0014 0895              ret
				 0016                   .dbend
				 0016                   .dbfunc e timer0_init _timer0_init fV
				                        .even
				 0016           _timer0_init::
				 0016                   .dbline -1
				 0016                   .dbline 26
				 0016           ; }
				 0016           ; 
				 0016           ; //TIMER0 initialize - prescale:1024
				 0016           ; // WGM: Normal
				 0016           ; // desired value: 25mSec
				 0016           ; // actual value: 24.960mSec (0.2%)
				 0016           ; void timer0_init(void)
				 0016           ; {
				 0016                   .dbline 27
				 0016           ;  TCCR0 = 0x00; //stop
				 0016 2224              clr R2
				 0018 23BE              out 0x33,R2
				 001A                   .dbline 28
				 001A           ;  TCNT0 = 0x3D; //set count
				 001A 8DE3              ldi R24,61
				 001C 82BF              out 0x32,R24
				 001E                   .dbline 29
				 001E           ;  OCR0  = 0xC3;  //set compare
				 001E 83EC              ldi R24,195
				 0020 8CBF              out 0x3c,R24
				 0022                   .dbline 30
				 0022           ;  TCCR0 = 0x05; //start timer
				 0022 85E0              ldi R24,5
				 0024 83BF              out 0x33,R24
				 0026                   .dbline -2
				 0026           L2:
				 0026                   .dbline 0 ; func end
				 0026 0895              ret
				 0028                   .dbend
				                        .area vector(rom, abs)
				                        .org 36
				 0024 0C941400          jmp _timer0_ovf_isr
				                        .area text(rom, con, rel)
				 0028                   .dbfile F:\try\DS18B20\main_18b20.c
				 0028                   .dbfunc e timer0_ovf_isr _timer0_ovf_isr fV
				                        .even
				 0028           _timer0_ovf_isr::
				 0028 8A93              st -y,R24
				 002A 8FB7              in R24,0x3f
				 002C 8A93              st -y,R24
				 002E                   .dbline -1
				 002E                   .dbline 35
				 002E           ; }
				 002E           ; 
				 002E           ; #pragma interrupt_handler timer0_ovf_isr:iv_TIM0_OVF
				 002E           ; void timer0_ovf_isr(void)
				 002E           ; {
				 002E                   .dbline 36
				 002E           ;  TCNT0 = 0x3D; //reload counter value
				 002E 8DE3              ldi R24,61
				 0030 82BF              out 0x32,R24
				 0032                   .dbline -2
				 0032           L3:
				 0032                   .dbline 0 ; func end
				 0032 8991              ld R24,y+
				 0034 8FBF              out 0x3f,R24
				 0036 8991              ld R24,y+
				 0038 1895              reti
				 003A                   .dbend
				 003A                   .dbfunc e uart0_init _uart0_init fV
				                        .even
				 003A           _uart0_init::
				 003A                   .dbline -1
				 003A                   .dbline 43
				 003A           ; }
				 003A           ; 
				 003A           ; //UART0 initialize
				 003A           ; // desired baud rate: 9600
				 003A           ; // actual: baud rate:9615 (0.2%)
				 003A           ; void uart0_init(void)
				 003A           ; {
				 003A                   .dbline 44
				 003A           ;  UCSRB = 0x00; //disable while setting baud rate
				 003A 2224              clr R2
				 003C 2AB8              out 0xa,R2
				 003E                   .dbline 45
				 003E           ;  UCSRA = 0x00;
				 003E 2BB8              out 0xb,R2
				 0040                   .dbline 46
				 0040           ;  UCSRC = BIT(URSEL) | 0x06;
				 0040 86E8              ldi R24,134
				 0042 80BD              out 0x20,R24
				 0044                   .dbline 47
				 0044           ;  UBRRL = 0x33; //set baud rate lo
				 0044 83E3              ldi R24,51
				 0046 89B9              out 0x9,R24
				 0048                   .dbline 48
				 0048           ;  UBRRH = 0x00; //set baud rate hi
				 0048 20BC              out 0x20,R2
				 004A                   .dbline 49
				 004A           ;  UCSRB = 0x98;
				 004A 88E9              ldi R24,152
				 004C 8AB9              out 0xa,R24
				 004E                   .dbline -2
				 004E           L4:
				 004E                   .dbline 0 ; func end
				 004E 0895              ret
				 0050                   .dbend
				                        .area vector(rom, abs)
				                        .org 44
				 002C 0C942800          jmp _uart0_rx_isr
				                        .area text(rom, con, rel)
				 0050                   .dbfile F:\try\DS18B20\main_18b20.c
				 0050                   .dbfunc e uart0_rx_isr _uart0_rx_isr fV
				                        .even
				 0050           _uart0_rx_isr::
				 0050                   .dbline -1
				 0050                   .dbline 54
				 0050           ; }
				 0050           ; 
				 0050           ; #pragma interrupt_handler uart0_rx_isr:iv_USART0_RXC
				 0050           ; void uart0_rx_isr(void)
				 0050           ; {
				 0050                   .dbline -2
				 0050           L5:
				 0050                   .dbline 0 ; func end
				 0050 1895              reti
				 0052                   .dbend
				 0052                   .dbfunc e init_devices _init_devices fV
				                        .even
				 0052           _init_devices::
				 0052                   .dbline -1
				 0052                   .dbline 60
				 0052           ;  //uart has received a character in UDR
				 0052           ; }
				 0052           ; 
				 0052           ; //call this routine to initialize all peripherals
				 0052           ; void init_devices(void)
				 0052           ; {
				 0052                   .dbline 62
				 0052           ;  //stop errant interrupts until set up
				 0052           ;  CLI(); //disable all interrupts
				 0052 F894              cli
				 0054                   .dbline 63
				 0054           ;  port_init();
				 0054 D5DF              xcall _port_init
				 0056                   .dbline 64
				 0056           ;  timer0_init();
				 0056 DFDF              xcall _timer0_init
				 0058                   .dbline 65
				 0058           ;  uart0_init();
				 0058 F0DF              xcall _uart0_init
				 005A                   .dbline 67
				 005A           ; 
				 005A           ;  MCUCR = 0x00;
				 005A 2224              clr R2
				 005C 25BE              out 0x35,R2
				 005E                   .dbline 68
				 005E           ;  GICR  = 0x00;
				 005E 2BBE              out 0x3b,R2
				 0060                   .dbline 69
				 0060           ;  TIMSK = 0x01; //timer interrupt sources
				 0060 81E0              ldi R24,1
				 0062 89BF              out 0x39,R24
				 0064                   .dbline 70
				 0064           ;  SEI(); //re-enable interrupts
				 0064 7894              sei
				 0066                   .dbline -2
				 0066           L6:
				 0066                   .dbline 0 ; func end
				 0066 0895              ret
				 0068                   .dbend
				 0068                   .dbfunc e putchar _putchar fV
				 0068           ;          TmpCh -> R16
				                        .even
				 0068           _putchar::
				 0068                   .dbline -1
				 0068                   .dbline 76
				 0068           ;  //all peripherals are now initialized
				 0068           ; }
				 0068           ; 
				 0068           ;  //输出一个字符
				 0068           ; void putchar(unsigned char TmpCh)
				 0068           ; {     
				 0068           L8:
				 0068                   .dbline 77
				 0068           ;       while( !(UCSRA & (1				 0068           L9:
				 0068                   .dbline 77
				 0068 5D9B              sbis 0xb,5
				 006A FECF              rjmp L8
				 006C           X0:
				 006C                   .dbline 78
				 006C           ;       UDR = TmpCh;    
				 006C 0CB9              out 0xc,R16
				 006E                   .dbline -2
				 006E           L7:
				 006E                   .dbline 0 ; func end
				 006E 0895              ret
				 0070                   .dbsym r TmpCh 16 c
				 0070                   .dbend
				 0070                   .dbfunc e main _main fV
				 0070           ;        tempout -> R10
				                        .even
				 0070           _main::
				 0070                   .dbline -1
				 0070                   .dbline 82
				 0070           ; }
				 0070           ; 
				 0070           ; void main(void)
				 0070           ; {
				 0070                   .dbline 83
				 0070           ;   unsigned char tempout = 0;
				 0070 AA24              clr R10
				 0072                   .dbline 84
				 0072           ;   init_devices();
				 0072 EFDF              xcall _init_devices
				 0074                   .dbline 85
				 0074           ;   init_1820();
				 0074 0E940000          xcall _init_1820
				 0078                   .dbline 86
				 0078           ;   putchar(0xFF);
				 0078 0FEF              ldi R16,255
				 007A F6DF              xcall _putchar
				 007C                   .dbline 87
				 007C           ;   delay_nms(200);
				 007C 08EC              ldi R16,200
				 007E 10E0              ldi R17,0
				 0080 0E940000          xcall _delay_nms
				 0084                   .dbline 88
				 0084           ;   ;
				 0084 0DC0              xjmp L13
				 0086           L12:
				 0086                   .dbline 90
				 0086           ;   while(1)
				 0086           ;      {
				 0086                   .dbline 91
				 0086           ;         tempout = gettemp();
				 0086 0E940000          xcall _gettemp
				 008A A02E              mov R10,R16
				 008C                   .dbline 92
				 008C           ;         delay_nms(30);
				 008C 0EE1              ldi R16,30
				 008E 10E0              ldi R17,0
				 0090 0E940000          xcall _delay_nms
				 0094                   .dbline 93
				 0094           ;         putchar(tempout);
				 0094 0A2D              mov R16,R10
				 0096 E8DF              xcall _putchar
				 0098                   .dbline 95
				 0098           ;         //putchar(wml);
				 0098           ;         delay_nms(3000); 
				 0098 08EB              ldi R16,3000
				 009A 1BE0              ldi R17,11
				 009C 0E940000          xcall _delay_nms
				 00A0                   .dbline 96
				 00A0           ;        };
				 00A0           L13:
				 00A0                   .dbline 89
				 00A0 F2CF              xjmp L12
				 00A2           X1:
				 00A2                   .dbline -2
				 00A2           L11:
				 00A2                   .dbline 0 ; func end
				 00A2 0895              ret
				 00A4                   .dbsym r tempout 10 c
				 00A4                   .dbend
				 00A4           ; };
							

相关资源