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

📄 main.lss

📁 avr单片机操作温度传感器18B20的软件含仿真。
💻 LSS
📖 第 1 页 / 共 3 页
字号:
	__asm__ volatile (
 2a2:	01 97       	sbiw	r24, 0x01	; 1
 2a4:	f1 f7       	brne	.-4      	; 0x2a2
   	 LCD_DATA_PORT &= 0X0f; //portd4~7=0 
   	 LCD_DATA_PORT |= data_in&0xf0; //send high 4bit
	 LCD_EN_PORT |= LCD_EN; //EN端产生一个由低电平变高电平,写LCD
	 DELAY_nus(1);
     LCD_EN_PORT &= ~LCD_EN; //EN端产生一个由高电平变低电平,写LCD
 2a6:	dd 98       	cbi	0x1b, 5	; 27
    milliseconds can be achieved.
 */
static __inline__ void
_delay_loop_2(uint16_t __count)
{
 2a8:	89 e2       	ldi	r24, 0x29	; 41
 2aa:	90 e0       	ldi	r25, 0x00	; 0
	__asm__ volatile (
 2ac:	01 97       	sbiw	r24, 0x01	; 1
 2ae:	f1 f7       	brne	.-4      	; 0x2ac
 2b0:	08 95       	ret

000002b2 <LCD_write_char>:
编写日期          :2003-11-19 
最后修改日期      :2004-8-19 		
-----------------------------------------------------------------------*/
void LCD_write_char(unsigned command,unsigned data)
  { unsigned char data_temp;
 2b2:	1f 93       	push	r17
    data_temp =0x00;   
    if (command == 0)
 2b4:	89 2b       	or	r24, r25
 2b6:	11 f4       	brne	.+4      	; 0x2bc
   	LCD_RS_PORT &= ~LCD_RS;   // RS=0 写命令模式
 2b8:	dc 98       	cbi	0x1b, 4	; 27
 2ba:	01 c0       	rjmp	.+2      	; 0x2be
	else
    LCD_RS_PORT |= LCD_RS;    // RS=1 写数据模式
 2bc:	dc 9a       	sbi	0x1b, 4	; 27
	
    data_temp = data;
 2be:	16 2f       	mov	r17, r22
    LCD_Write_half_char(data_temp);    // 先写高四位
 2c0:	86 2f       	mov	r24, r22
 2c2:	99 27       	eor	r25, r25
 2c4:	0e 94 46 01 	call	0x28c
	data_temp = data;
	data_temp=data_temp << 4; // 再写低四位
 2c8:	12 95       	swap	r17
 2ca:	10 7f       	andi	r17, 0xF0	; 240
    LCD_Write_half_char(data_temp);
 2cc:	81 2f       	mov	r24, r17
 2ce:	99 27       	eor	r25, r25
 2d0:	0e 94 46 01 	call	0x28c
 2d4:	1f 91       	pop	r17
 2d6:	08 95       	ret

000002d8 <LCD_clr>:
 2d8:	61 e0       	ldi	r22, 0x01	; 1
 2da:	70 e0       	ldi	r23, 0x00	; 0
 2dc:	80 e0       	ldi	r24, 0x00	; 0
 2de:	90 e0       	ldi	r25, 0x00	; 0
 2e0:	0e 94 59 01 	call	0x2b2
 2e4:	08 95       	ret

000002e6 <LCD_init>:
 2e6:	87 b3       	in	r24, 0x17	; 23
 2e8:	80 6f       	ori	r24, 0xF0	; 240
 2ea:	87 bb       	out	0x17, r24	; 23
 2ec:	8a b3       	in	r24, 0x1a	; 26
 2ee:	80 63       	ori	r24, 0x30	; 48
 2f0:	8a bb       	out	0x1a, r24	; 26
 2f2:	80 e2       	ldi	r24, 0x20	; 32
 2f4:	88 bb       	out	0x18, r24	; 24
 2f6:	dd 9a       	sbi	0x1b, 5	; 27
    milliseconds can be achieved.
 */
static __inline__ void
_delay_loop_2(uint16_t __count)
{
 2f8:	89 e2       	ldi	r24, 0x29	; 41
 2fa:	90 e0       	ldi	r25, 0x00	; 0
	__asm__ volatile (
 2fc:	01 97       	sbiw	r24, 0x01	; 1
 2fe:	f1 f7       	brne	.-4      	; 0x2fc
	LCD_EN_RS_DDR |= LCD_RS | LCD_EN;
	LCD_DATA_PORT = 0x20;//不知道什么意思
	LCD_EN_PORT |= LCD_EN; // Write data to LCD
	DELAY_nus(1);
	LCD_EN_PORT &= ~LCD_EN;// Disable LCD
 300:	dd 98       	cbi	0x1b, 5	; 27
    milliseconds can be achieved.
 */
static __inline__ void
_delay_loop_2(uint16_t __count)
{
 302:	8a e7       	ldi	r24, 0x7A	; 122
 304:	96 e0       	ldi	r25, 0x06	; 6
	__asm__ volatile (
 306:	01 97       	sbiw	r24, 0x01	; 1
 308:	f1 f7       	brne	.-4      	; 0x306
	LCD_EN_PORT |= LCD_EN; // Write data to LCD
	DELAY_nus(1);
	LCD_EN_PORT &= ~LCD_EN;// Disable LCD
	DELAY_nus(40);
    LCD_write_char(0,0x28);      //4bit test写命令//0X38为8位数据
 30a:	68 e2       	ldi	r22, 0x28	; 40
 30c:	70 e0       	ldi	r23, 0x00	; 0
 30e:	80 e0       	ldi	r24, 0x00	; 0
 310:	90 e0       	ldi	r25, 0x00	; 0
 312:	0e 94 59 01 	call	0x2b2
    LCD_write_char(0,0x0c);      //显示开
 316:	6c e0       	ldi	r22, 0x0C	; 12
 318:	70 e0       	ldi	r23, 0x00	; 0
 31a:	80 e0       	ldi	r24, 0x00	; 0
 31c:	90 e0       	ldi	r25, 0x00	; 0
 31e:	0e 94 59 01 	call	0x2b2
    LCD_write_char(0,0x01);      //显示清屏
 322:	61 e0       	ldi	r22, 0x01	; 1
 324:	70 e0       	ldi	r23, 0x00	; 0
 326:	80 e0       	ldi	r24, 0x00	; 0
 328:	90 e0       	ldi	r25, 0x00	; 0
 32a:	0e 94 59 01 	call	0x2b2
    LCD_write_char(0,0x06);      //显示光标移动设置
 32e:	66 e0       	ldi	r22, 0x06	; 6
 330:	70 e0       	ldi	r23, 0x00	; 0
 332:	80 e0       	ldi	r24, 0x00	; 0
 334:	90 e0       	ldi	r25, 0x00	; 0
 336:	0e 94 59 01 	call	0x2b2
 33a:	08 95       	ret

0000033c <LCD_set_xy>:
  }
/************************************************************************/
/* LCD1602清屏                                                          */
/************************************************************************/
void LCD_clr(void)
	{
	LCD_write_char(0,0x01);
	}
/*-----------------------------------------------------------------------
LCD_write_char    : 英文字符串显示函数

输入参数:*s      :英文字符串指针;
          X、Y    : 显示字符串的位置,X:0-15,Y:0-1
                    LCD第一行显示寄存器地址:0X80-0X8F
                    LCD第一行显示寄存器地址:0XC0-0XCF

编写日期          :2003-11-19 
最后修改日期      :2004-8-19 		
-----------------------------------------------------------------------*/
void LCD_write_char(unsigned command,unsigned data)
  { unsigned char data_temp;
    data_temp =0x00;   
    if (command == 0)
   	LCD_RS_PORT &= ~LCD_RS;   // RS=0 写命令模式
	else
    LCD_RS_PORT |= LCD_RS;    // RS=1 写数据模式
	
    data_temp = data;
    LCD_Write_half_char(data_temp);    // 先写高四位
	data_temp = data;
	data_temp=data_temp << 4; // 再写低四位
    LCD_Write_half_char(data_temp);
	//DELAY_nus(1);	 
  }
/*---------写高4bit到LCD,4到7位连接----*/
void LCD_Write_half_char(unsigned data_in)
  {
   	 LCD_DATA_PORT &= 0X0f; //portd4~7=0 
   	 LCD_DATA_PORT |= data_in&0xf0; //send high 4bit
	 LCD_EN_PORT |= LCD_EN; //EN端产生一个由低电平变高电平,写LCD
	 DELAY_nus(1);
     LCD_EN_PORT &= ~LCD_EN; //EN端产生一个由高电平变低电平,写LCD
   	 //LCD_DATA_PORT &= 0X0f; 
	 DELAY_nus(1); 
   }

/*-----------------------------------------------------------------------
LCD_set_xy        : 设置LCD显示的起始位置

输入参数:x、y    : 显示字符串的位置,X:0-15,Y:0-1
                    LCD第一行显示寄存器地址:0X80-0X8F
                    LCD第一行显示寄存器地址:0XC0-0XCF

编写日期          :2004-8-19 
最后修改日期      :2004-8-19 		
-----------------------------------------------------------------------*/
void LCD_set_xy( unsigned char x, unsigned char y )
  {
 33c:	98 2f       	mov	r25, r24
    unsigned char address;
    if (y == 0) address = 0x80 + x; 
 33e:	66 23       	and	r22, r22
 340:	19 f4       	brne	.+6      	; 0x348
 342:	89 2f       	mov	r24, r25
 344:	80 58       	subi	r24, 0x80	; 128
 346:	02 c0       	rjmp	.+4      	; 0x34c
	//数据指针位置为80H加上地址码(00H-27H,40H-67H)                               //
    else 
       address = 0xc0 + x;
 348:	89 2f       	mov	r24, r25
 34a:	80 54       	subi	r24, 0x40	; 64
    LCD_write_char(0,address);//
 34c:	99 27       	eor	r25, r25
 34e:	bc 01       	movw	r22, r24
 350:	80 e0       	ldi	r24, 0x00	; 0
 352:	90 e0       	ldi	r25, 0x00	; 0
 354:	0e 94 59 01 	call	0x2b2
 358:	08 95       	ret

0000035a <LCD_write_string>:
  }
/*-----------------------------------------------------------------------
LCD_write_string  : 英文字符串显示函数

输入参数:*s      :英文字符串指针;
          X、Y    : 显示字符串的位置

编写日期          :2004-8-19 
最后修改日期      :2004-8-19 		
-----------------------------------------------------------------------*/
void LCD_write_string(unsigned char X,unsigned char Y,unsigned char *s)
  {
 35a:	cf 93       	push	r28
 35c:	df 93       	push	r29
 35e:	ea 01       	movw	r28, r20
    LCD_set_xy( X, Y );
 360:	0e 94 9e 01 	call	0x33c
    
    while (*s) 
      {
        LCD_write_char(1,*s);
	s ++;
 364:	88 81       	ld	r24, Y
 366:	88 23       	and	r24, r24
 368:	51 f0       	breq	.+20     	; 0x37e
 36a:	89 91       	ld	r24, Y+
 36c:	99 27       	eor	r25, r25
 36e:	bc 01       	movw	r22, r24
 370:	81 e0       	ldi	r24, 0x01	; 1
 372:	90 e0       	ldi	r25, 0x00	; 0
 374:	0e 94 59 01 	call	0x2b2
 378:	88 81       	ld	r24, Y
 37a:	88 23       	and	r24, r24
 37c:	b1 f7       	brne	.-20     	; 0x36a
 37e:	df 91       	pop	r29
 380:	cf 91       	pop	r28
 382:	08 95       	ret

00000384 <main>:
unsigned int i=0;
char cc1[]="Temprature!";
char cc2[]="+000 Degree";
int main(void)
{
 384:	cf e5       	ldi	r28, 0x5F	; 95
 386:	d4 e0       	ldi	r29, 0x04	; 4
 388:	de bf       	out	0x3e, r29	; 62
 38a:	cd bf       	out	0x3d, r28	; 61

	//port_init();
	USART_init();
 38c:	0e 94 07 01 	call	0x20e
	LCD_init();
 390:	0e 94 73 01 	call	0x2e6
	LCD_clr();
 394:	0e 94 6c 01 	call	0x2d8
	ds18b20_config();
 398:	0e 94 59 00 	call	0xb2
	DELAY_nms(30);
 39c:	8e e1       	ldi	r24, 0x1E	; 30
 39e:	90 e0       	ldi	r25, 0x00	; 0
 3a0:	0e 94 4d 00 	call	0x9a
    LCD_write_string(0,0,cc1);
 3a4:	4c e6       	ldi	r20, 0x6C	; 108
 3a6:	50 e0       	ldi	r21, 0x00	; 0
 3a8:	60 e0       	ldi	r22, 0x00	; 0
 3aa:	86 2f       	mov	r24, r22
 3ac:	0e 94 ad 01 	call	0x35a
	DELAY_nms(30);
 3b0:	8e e1       	ldi	r24, 0x1E	; 30
 3b2:	90 e0       	ldi	r25, 0x00	; 0
 3b4:	0e 94 4d 00 	call	0x9a
	if (ds18b20_reset()) {
 3b8:	0e 94 5c 00 	call	0xb8
 3bc:	68 2f       	mov	r22, r24
 3be:	88 23       	and	r24, r24
 3c0:	21 f0       	breq	.+8      	; 0x3ca
		LCD_write_string(14,0,"ok");
 3c2:	48 e7       	ldi	r20, 0x78	; 120
 3c4:	50 e0       	ldi	r21, 0x00	; 0
 3c6:	60 e0       	ldi	r22, 0x00	; 0
 3c8:	02 c0       	rjmp	.+4      	; 0x3ce
		}
	else LCD_write_string(14,0,"no");
 3ca:	4b e7       	ldi	r20, 0x7B	; 123
 3cc:	50 e0       	ldi	r21, 0x00	; 0
 3ce:	8e e0       	ldi	r24, 0x0E	; 14
 3d0:	0e 94 ad 01 	call	0x35a
	/*while(1)
		{   
			ds18b20_reset();
			DELAY_nms(250);//用户应等待几百个* 毫秒
			convert_T();
			DELAY_nms(100);
			i=read_T();
			DS18B20_HEX_to_LCD(i,cc2);
			DELAY_nus(50);
			LCD_write_string(3,1,cc2);
			DELAY_nus(50);
			//put_str(cc1);
		    //put_char('\n');
			//put_str(cc2);
			
	    }
	*/
}
 3d4:	80 e0       	ldi	r24, 0x00	; 0
 3d6:	90 e0       	ldi	r25, 0x00	; 0
 3d8:	0c 94 fa 01 	jmp	0x3f4

000003dc <__udivmodqi4>:
 3dc:	99 1b       	sub	r25, r25
 3de:	79 e0       	ldi	r23, 0x09	; 9
 3e0:	04 c0       	rjmp	.+8      	; 0x3ea

000003e2 <__udivmodqi4_loop>:
 3e2:	99 1f       	adc	r25, r25
 3e4:	96 17       	cp	r25, r22
 3e6:	08 f0       	brcs	.+2      	; 0x3ea
 3e8:	96 1b       	sub	r25, r22

000003ea <__udivmodqi4_ep>:
 3ea:	88 1f       	adc	r24, r24
 3ec:	7a 95       	dec	r23
 3ee:	c9 f7       	brne	.-14     	; 0x3e2
 3f0:	80 95       	com	r24
 3f2:	08 95       	ret

000003f4 <_exit>:
 3f4:	ff cf       	rjmp	.-2      	; 0x3f4

⌨️ 快捷键说明

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