⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ds18b20.lst

📁 F:程序DS18B20.rar索读取温度
💻 LST
📖 第 1 页 / 共 2 页
字号:
__text_start:
__start:
      72 EFCF      LDI	R28,0xFF
      73 E2D1      LDI	R29,0x21
      74 BFCD      OUT	0x3D,R28
      75 BFDE      OUT	0x3E,R29
      76 51CE      SUBI	R28,0x1E
      77 40D0      SBCI	R29,0
      78 EA0A      LDI	R16,0xAA
      79 8308      STD	Y+0,R16
      7A 2400      CLR	R0
      7B E0E0      LDI	R30,0
      7C E0F2      LDI	R31,2
      7D E012      LDI	R17,2
      7E 30E2      CPI	R30,2
      7F 07F1      CPC	R31,R17
      80 F011      BEQ	0x0083
      81 9201      ST	R0,Z+
      82 CFFB      RJMP	0x007E
      83 8300      STD	Z+0,R16
      84 EEE4      LDI	R30,0xE4
      85 E0F0      LDI	R31,0
      86 E0A0      LDI	R26,0
      87 E0B2      LDI	R27,2
      88 E010      LDI	R17,0
      89 E000      LDI	R16,0
      8A BF0B      OUT	0x3B,R16
      8B 3EE4      CPI	R30,0xE4
      8C 07F1      CPC	R31,R17
      8D F021      BEQ	0x0092
      8E 95C8      LPM
      8F 9631      ADIW	R30,1
      90 920D      ST	R0,X+
      91 CFF9      RJMP	0x008B
      92 940E 00CD CALL	_main
_exit:
      94 CFFF      RJMP	_exit
FILE: F:\try\DS18B20\main_18b20.c
(0001) //ICC-AVR application builder : 2008-4-7 PM 04:31:51
(0002) // Target : M16
(0003) // Crystal: 8.0000Mhz
(0004) 
(0005) #include <iom16v.h>
(0006) #include <macros.h>
(0007) #include "DS18B20.h"
(0008) 
(0009) void port_init(void)
(0010) {
(0011)  PORTA = 0x00;
_port_init:
      95 2422      CLR	R2
      96 BA2B      OUT	0x1B,R2
(0012)  DDRA  = 0x00;
      97 BA2A      OUT	0x1A,R2
(0013)  PORTB = 0x00;
      98 BA28      OUT	0x18,R2
(0014)  DDRB  = 0x00;
      99 BA27      OUT	0x17,R2
(0015)  PORTC = 0x00; //m103 output only
      9A BA25      OUT	0x15,R2
(0016)  DDRC  = 0xFF;
      9B EF8F      LDI	R24,0xFF
      9C BB84      OUT	0x14,R24
(0017)  PORTD = 0x00;
      9D BA22      OUT	0x12,R2
(0018)  DDRD  = 0x00;
      9E BA21      OUT	0x11,R2
      9F 9508      RET
(0019) }
(0020) 
(0021) //TIMER0 initialize - prescale:1024
(0022) // WGM: Normal
(0023) // desired value: 25mSec
(0024) // actual value: 24.960mSec (0.2%)
(0025) void timer0_init(void)
(0026) {
(0027)  TCCR0 = 0x00; //stop
_timer0_init:
      A0 2422      CLR	R2
      A1 BE23      OUT	0x33,R2
(0028)  TCNT0 = 0x3D; //set count
      A2 E38D      LDI	R24,0x3D
      A3 BF82      OUT	0x32,R24
(0029)  OCR0  = 0xC3;  //set compare
      A4 EC83      LDI	R24,0xC3
      A5 BF8C      OUT	0x3C,R24
(0030)  TCCR0 = 0x05; //start timer
      A6 E085      LDI	R24,5
      A7 BF83      OUT	0x33,R24
      A8 9508      RET
_timer0_ovf_isr:
      A9 938A      ST	R24,-Y
      AA B78F      IN	R24,0x3F
      AB 938A      ST	R24,-Y
(0031) }
(0032) 
(0033) #pragma interrupt_handler timer0_ovf_isr:iv_TIM0_OVF
(0034) void timer0_ovf_isr(void)
(0035) {
(0036)  TCNT0 = 0x3D; //reload counter value
      AC E38D      LDI	R24,0x3D
      AD BF82      OUT	0x32,R24
      AE 9189      LD	R24,Y+
      AF BF8F      OUT	0x3F,R24
      B0 9189      LD	R24,Y+
      B1 9518      RETI
(0037) }
(0038) 
(0039) //UART0 initialize
(0040) // desired baud rate: 9600
(0041) // actual: baud rate:9615 (0.2%)
(0042) void uart0_init(void)
(0043) {
(0044)  UCSRB = 0x00; //disable while setting baud rate
_uart0_init:
      B2 2422      CLR	R2
      B3 B82A      OUT	0x0A,R2
(0045)  UCSRA = 0x00;
      B4 B82B      OUT	0x0B,R2
(0046)  UCSRC = BIT(URSEL) | 0x06;
      B5 E886      LDI	R24,0x86
      B6 BD80      OUT	0x20,R24
(0047)  UBRRL = 0x33; //set baud rate lo
      B7 E383      LDI	R24,0x33
      B8 B989      OUT	0x09,R24
(0048)  UBRRH = 0x00; //set baud rate hi
      B9 BC20      OUT	0x20,R2
(0049)  UCSRB = 0x98;
      BA E988      LDI	R24,0x98
      BB B98A      OUT	0x0A,R24
      BC 9508      RET
(0050) }
(0051) 
(0052) #pragma interrupt_handler uart0_rx_isr:iv_USART0_RXC
(0053) void uart0_rx_isr(void)
(0054) {
_uart0_rx_isr:
      BD 9518      RETI
(0055)  //uart has received a character in UDR
(0056) }
(0057) 
(0058) //call this routine to initialize all peripherals
(0059) void init_devices(void)
(0060) {
(0061)  //stop errant interrupts until set up
(0062)  CLI(); //disable all interrupts
_init_devices:
      BE 94F8      BCLR	7
(0063)  port_init();
      BF DFD5      RCALL	_port_init
(0064)  timer0_init();
      C0 DFDF      RCALL	_timer0_init
(0065)  uart0_init();
      C1 DFF0      RCALL	_uart0_init
(0066) 
(0067)  MCUCR = 0x00;
      C2 2422      CLR	R2
      C3 BE25      OUT	0x35,R2
(0068)  GICR  = 0x00;
      C4 BE2B      OUT	0x3B,R2
(0069)  TIMSK = 0x01; //timer interrupt sources
      C5 E081      LDI	R24,1
      C6 BF89      OUT	0x39,R24
(0070)  SEI(); //re-enable interrupts
      C7 9478      BSET	7
      C8 9508      RET
(0071)  //all peripherals are now initialized
(0072) }
(0073) 
(0074)  //输出一个字符
(0075) void putchar(unsigned char TmpCh)
(0076) {	
(0077) 	while( !(UCSRA & (1<<UDRE)) );
_putchar:
  TmpCh                --> R16
      C9 9B5D      SBIS	0x0B,5
      CA CFFE      RJMP	_putchar
(0078) 	UDR = TmpCh;	
      CB B90C      OUT	0x0C,R16
      CC 9508      RET
(0079) }
(0080) 
(0081) void main(void)
(0082) {
(0083)   unsigned char tempout = 0;
_main:
  tempout              --> R10
      CD 24AA      CLR	R10
(0084)   init_devices();
      CE DFEF      RCALL	_init_devices
(0085)   init_1820();
      CF 940E 00E7 CALL	_init_1820
(0086)   putchar(0xFF);
      D1 EF0F      LDI	R16,0xFF
      D2 DFF6      RCALL	_putchar
(0087)   delay_nms(200);
      D3 EC08      LDI	R16,0xC8
      D4 E010      LDI	R17,0
      D5 940E 016F CALL	_delay_nms
(0088)   ;
      D7 C00D      RJMP	0x00E5
(0089)   while(1)
(0090)      {
(0091) 	  tempout = gettemp();
      D8 940E 0137 CALL	_gettemp
      DA 2EA0      MOV	R10,R16
(0092) 	  delay_nms(30);
      DB E10E      LDI	R16,0x1E
      DC E010      LDI	R17,0
      DD 940E 016F CALL	_delay_nms
(0093) 	  putchar(tempout);
      DF 2D0A      MOV	R16,R10
      E0 DFE8      RCALL	_putchar
(0094) 	  //putchar(wml);
(0095) 	  delay_nms(3000); 
      E1 EB08      LDI	R16,0xB8
      E2 E01B      LDI	R17,0xB
      E3 940E 016F CALL	_delay_nms
      E5 CFF2      RJMP	0x00D8
      E6 9508      RET
FILE: F:\try\DS18B20\DS18B20.C
(0001) /************************************************************************* 
(0002) ds18b20头文件    
(0003) M16  内部8M         
(0004) *************************************************************************/ 
(0005) #include <iom16v.h>
(0006) #include <macros.h>
(0007) #include "DS18B20.h"
(0008) 
(0009) #define CLR_DIR_1WIRE DDRC&=~BIT(2)   
(0010)   //只要修改这里的参数就可以了!呵呵! 
(0011) #define SET_DIR_1WIRE DDRC|=BIT(2)     
(0012)  //里面什么都不用该! 
(0013) #define CLR_OP_1WIRE PORTC&=~BIT(2) 
(0014) #define SET_OP_1WIRE PORTC|=BIT(2)       
(0015) #define CHECK_IP_1WIRE (PINC & 0x04)   
(0016)  //检测 
(0017) unsigned char wmh,wml; 
(0018) void init_1820(void)  
(0019) {  
(0020)     SET_DIR_1WIRE;                //设置PC2 为输出 
_init_1820:
      E7 9AA2      SBI	0x14,2
(0021)     SET_OP_1WIRE;   
      E8 9AAA      SBI	0x15,2
(0022)     CLR_OP_1WIRE;  
      E9 98AA      CBI	0x15,2
(0023)     delay_nus(500);    //480us以上  
      EA EF04      LDI	R16,0xF4
      EB E011      LDI	R17,1
      EC D06A      RCALL	_delay_nus
(0024)     SET_OP_1WIRE;  
      ED 9AAA      SBI	0x15,2
(0025)     CLR_DIR_1WIRE;  
      EE 98A2      CBI	0x14,2
(0026)     delay_nus(25);     //15~60us  
      EF E109      LDI	R16,0x19
      F0 E010      LDI	R17,0
      F1 D065      RCALL	_delay_nus
(0027)     while(CHECK_IP_1WIRE);  
      F2 999A      SBIC	0x13,2
      F3 CFFE      RJMP	0x00F2
(0028)     SET_DIR_1WIRE;  
      F4 9AA2      SBI	0x14,2
(0029)     SET_OP_1WIRE;  
      F5 9AAA      SBI	0x15,2
(0030)     delay_nus(180);   //60~240us  
      F6 EB04      LDI	R16,0xB4
      F7 E010      LDI	R17,0
      F8 D05E      RCALL	_delay_nus
      F9 9508      RET
_write_1820:
  m                    --> R20
  x                    --> R10
      FA 92AA      ST	R10,-Y
      FB 934A      ST	R20,-Y
      FC 2EA0      MOV	R10,R16
(0031) }  
(0032) void write_1820(unsigned char x)  
(0033) {     
(0034)      unsigned char m;  
(0035)     for(m=0;m<8;m++)  
      FD 2744      CLR	R20

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -