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

📄 main.lss

📁 8个数码管显示时钟程序,LED数字钟,流水灯程序,红外遥控,键控看门狗程序
💻 LSS
📖 第 1 页 / 共 3 页
字号:
/* 写一个字节                                             */
/*                                                        */
/**********************************************************/
void WriteOneChar(uchar dat)
{
 11c:	1f 93       	push	r17
 11e:	cf 93       	push	r28
 120:	c8 2f       	mov	r28, r24
  uchar i = 0;
  
  for (i = 8; i > 0; i--)
 122:	18 e0       	ldi	r17, 0x08	; 8
  {
    PORTD&=~_BV(DQ);
 124:	93 98       	cbi	0x12, 3	; 18
 
    if(dat&0x01)
 126:	c0 ff       	sbrs	r28, 0
 128:	02 c0       	rjmp	.+4      	; 0x12e
     PORTD|=_BV(DQ);      //写"1" 
 12a:	93 9a       	sbi	0x12, 3	; 18
 12c:	01 c0       	rjmp	.+2      	; 0x130
	else     
	 PORTD&=~_BV(DQ);     //写"0"
 12e:	93 98       	cbi	0x12, 3	; 18

    Delay(70);
 130:	86 e4       	ldi	r24, 0x46	; 70
 132:	90 e0       	ldi	r25, 0x00	; 0
 134:	9c df       	rcall	.-200    	; 0x6e
    PORTD|=_BV(DQ);        
 136:	93 9a       	sbi	0x12, 3	; 18
    dat>>=1;
 138:	c6 95       	lsr	r28
 13a:	11 50       	subi	r17, 0x01	; 1
 13c:	99 f7       	brne	.-26     	; 0x124
 13e:	cf 91       	pop	r28
 140:	1f 91       	pop	r17
 142:	08 95       	ret

00000144 <Read_Temperature>:
  }
}

/*********************************************************/
/*                                                       */
/* 读取温度                                              */
/*                                                       */
/*********************************************************/
void Read_Temperature(void)
{
   Init_DS18B20();
 144:	b7 df       	rcall	.-146    	; 0xb4
   if(presence==1)
 146:	80 91 c3 00 	lds	r24, 0x00C3
 14a:	81 30       	cpi	r24, 0x01	; 1
 14c:	11 f4       	brne	.+4      	; 0x152
   { beep();}
 14e:	94 df       	rcall	.-216    	; 0x78
 150:	08 95       	ret
   else        
   {
     WriteOneChar(0xCC);  // 跳过读序号列号的操作
 152:	8c ec       	ldi	r24, 0xCC	; 204
 154:	e3 df       	rcall	.-58     	; 0x11c
     WriteOneChar(0x44);  // 启动温度转换
 156:	84 e4       	ldi	r24, 0x44	; 68
 158:	e1 df       	rcall	.-62     	; 0x11c

     Init_DS18B20();
 15a:	ac df       	rcall	.-168    	; 0xb4
     WriteOneChar(0xCC);  //跳过读序号列号的操作
 15c:	8c ec       	ldi	r24, 0xCC	; 204
 15e:	de df       	rcall	.-68     	; 0x11c
     WriteOneChar(0xBE);  //读取温度寄存器
 160:	8e eb       	ldi	r24, 0xBE	; 190
 162:	dc df       	rcall	.-72     	; 0x11c
     
     temp_data[0] = ReadOneChar();   //温度低8位
 164:	c5 df       	rcall	.-118    	; 0xf0
 166:	80 93 c1 00 	sts	0x00C1, r24
     temp_data[1] = ReadOneChar();   //温度高8位
 16a:	c2 df       	rcall	.-124    	; 0xf0
 16c:	80 93 c2 00 	sts	0x00C2, r24
 170:	08 95       	ret
 172:	08 95       	ret

00000174 <lcd_busy>:
    }
}

/*************************************************************/
/*                                                           */
/*  LCD初始化设定                                            */
/*                                                           */
/*************************************************************/
void lcd_init(void)
{
    DDRA=0XFF;          //设置PA输出
    PORTA=0XFF;         //全部加上上拉电阻
    DDRC=0XFF;          //设置PC为输出
    PORTC=0XFF;         //全部加上上拉电阻
	
    delay_nms(30);      //等待上电稳定
	
    lcd_wcmd(0x38,0);   //16*2显示,5*7点阵,8位数据
    delay_nms(5);
	lcd_wcmd(0x38,0);   //不进行忙检测   
    delay_nms(5);
	lcd_wcmd(0x38,0);      
    delay_nms(5);
	
    lcd_wcmd(0x0c,1);   //显示开,关光标
    delay_nms(5);
    lcd_wcmd(0x06,1);   //移动光标
    delay_nms(5);
    lcd_wcmd(0x01,1);   //清除LCD的显示内容
    delay_nms(5);
}

/*******************************************************************/
/*                                                                 */
/*写指令数据到LCD                                                  */
/*RS=L,RW=L,E=高脉冲,D0-D7=指令码。                             */
/*command为指令,wait_en指定是否要检测LCD忙信号                    */
/*                                                                 */
/*******************************************************************/
void lcd_wcmd(uchar command,uchar wait_en)
{   
    if(wait_en)             //若wait_en为1,则要检测LCD忙信号
    lcd_busy();
    PORTC &=~_BV(LCD_RS);   
    PORTC &=~_BV(LCD_RW);   
    PORTC &=~_BV(LCD_EN);   
    PORTA =command;         //送指令数据 
    PORTC |=_BV(LCD_EN);   
    _NOP();
    _NOP();
    PORTC &=~_BV(LCD_EN);   
}

/*******************************************************************/
/*                                                                 */
/*写显示数据到LCD                                                  */
/*RS=H,RW=L,E=高脉冲,D0-D7=数据。                               */
/*                                                                 */
/*******************************************************************/
void lcd_wdat(uchar dat)
{    
    lcd_busy();
    PORTC |=_BV(LCD_RS);    
    PORTC &=~_BV(LCD_RW);
    PORTC &=~_BV(LCD_EN);   
    PORTA=dat;               //送显示数据 
    PORTC |=_BV(LCD_EN);    
    _NOP();
    _NOP();
    PORTC &=~_BV(LCD_EN);  
}

/*************************************************************/
/*                                                           */
/*检查LCD忙状态                                              */
/*lcd_busy为1时,忙,等待。lcd-busy为0时,闲,可写指令与数据  */
/*                                                           */
/*************************************************************/ 
void lcd_busy(void)
{
    DDRA &=~_BV(busy);        //设置busy口为输入
 174:	d7 98       	cbi	0x1a, 7	; 26
    PORTC &=~_BV(LCD_RS);     
 176:	a8 98       	cbi	0x15, 0	; 21
    PORTC |= _BV(LCD_RW);      
 178:	a9 9a       	sbi	0x15, 1	; 21
    PORTC |= _BV(LCD_EN);     
 17a:	aa 9a       	sbi	0x15, 2	; 21
    while(PINA & _BV(busy)); //忙等待
 17c:	cf 99       	sbic	0x19, 7	; 25
 17e:	fe cf       	rjmp	.-4      	; 0x17c
    PORTC &=~_BV(LCD_EN);     
 180:	aa 98       	cbi	0x15, 2	; 21
    DDRA|=_BV(busy);          //设置busy口为输出 
 182:	d7 9a       	sbi	0x1a, 7	; 26
 184:	08 95       	ret

00000186 <lcd_wcmd>:
 186:	cf 93       	push	r28
 188:	c8 2f       	mov	r28, r24
 18a:	61 11       	cpse	r22, r1
 18c:	f3 df       	rcall	.-26     	; 0x174
 18e:	a8 98       	cbi	0x15, 0	; 21
 190:	a9 98       	cbi	0x15, 1	; 21
 192:	aa 98       	cbi	0x15, 2	; 21
 194:	cb bb       	out	0x1b, r28	; 27
 196:	aa 9a       	sbi	0x15, 2	; 21
 198:	00 00       	nop
 19a:	00 00       	nop
 19c:	aa 98       	cbi	0x15, 2	; 21
 19e:	cf 91       	pop	r28
 1a0:	08 95       	ret

000001a2 <lcd_init>:
 1a2:	8f ef       	ldi	r24, 0xFF	; 255
 1a4:	8a bb       	out	0x1a, r24	; 26
 1a6:	8b bb       	out	0x1b, r24	; 27
 1a8:	84 bb       	out	0x14, r24	; 20
 1aa:	85 bb       	out	0x15, r24	; 21
 1ac:	8e e1       	ldi	r24, 0x1E	; 30
 1ae:	90 e0       	ldi	r25, 0x00	; 0
 1b0:	53 df       	rcall	.-346    	; 0x58
 1b2:	60 e0       	ldi	r22, 0x00	; 0
 1b4:	88 e3       	ldi	r24, 0x38	; 56
 1b6:	e7 df       	rcall	.-50     	; 0x186
 1b8:	85 e0       	ldi	r24, 0x05	; 5
 1ba:	90 e0       	ldi	r25, 0x00	; 0
 1bc:	4d df       	rcall	.-358    	; 0x58
 1be:	60 e0       	ldi	r22, 0x00	; 0
 1c0:	88 e3       	ldi	r24, 0x38	; 56
 1c2:	e1 df       	rcall	.-62     	; 0x186
 1c4:	85 e0       	ldi	r24, 0x05	; 5
 1c6:	90 e0       	ldi	r25, 0x00	; 0
 1c8:	47 df       	rcall	.-370    	; 0x58
 1ca:	60 e0       	ldi	r22, 0x00	; 0
 1cc:	88 e3       	ldi	r24, 0x38	; 56
 1ce:	db df       	rcall	.-74     	; 0x186
 1d0:	85 e0       	ldi	r24, 0x05	; 5
 1d2:	90 e0       	ldi	r25, 0x00	; 0
 1d4:	41 df       	rcall	.-382    	; 0x58
 1d6:	61 e0       	ldi	r22, 0x01	; 1
 1d8:	8c e0       	ldi	r24, 0x0C	; 12
 1da:	d5 df       	rcall	.-86     	; 0x186
 1dc:	85 e0       	ldi	r24, 0x05	; 5
 1de:	90 e0       	ldi	r25, 0x00	; 0
 1e0:	3b df       	rcall	.-394    	; 0x58
 1e2:	61 e0       	ldi	r22, 0x01	; 1
 1e4:	86 e0       	ldi	r24, 0x06	; 6
 1e6:	cf df       	rcall	.-98     	; 0x186
 1e8:	85 e0       	ldi	r24, 0x05	; 5
 1ea:	90 e0       	ldi	r25, 0x00	; 0
 1ec:	35 df       	rcall	.-406    	; 0x58
 1ee:	61 e0       	ldi	r22, 0x01	; 1
 1f0:	86 2f       	mov	r24, r22
 1f2:	c9 df       	rcall	.-110    	; 0x186
 1f4:	85 e0       	ldi	r24, 0x05	; 5
 1f6:	90 e0       	ldi	r25, 0x00	; 0
 1f8:	2f df       	rcall	.-418    	; 0x58
 1fa:	08 95       	ret

000001fc <lcd_wdat>:
 1fc:	1f 93       	push	r17
 1fe:	18 2f       	mov	r17, r24
 200:	b9 df       	rcall	.-142    	; 0x174
 202:	a8 9a       	sbi	0x15, 0	; 21
 204:	a9 98       	cbi	0x15, 1	; 21
 206:	aa 98       	cbi	0x15, 2	; 21
 208:	1b bb       	out	0x1b, r17	; 27
 20a:	aa 9a       	sbi	0x15, 2	; 21
 20c:	00 00       	nop
 20e:	00 00       	nop
 210:	aa 98       	cbi	0x15, 2	; 21
 212:	1f 91       	pop	r17
 214:	08 95       	ret

00000216 <lcd_pos>:
}

/*************************************************************/
/*                                                           */
/*  设定显示位置                                             */
/*                                                           */
/*************************************************************/
void lcd_pos(uchar pos)
{                          
  lcd_wcmd(pos|0x80,1);  //数据指针=80+地址变量
 216:	61 e0       	ldi	r22, 0x01	; 1
 218:	80 68       	ori	r24, 0x80	; 128
 21a:	b5 df       	rcall	.-150    	; 0x186
 21c:	08 95       	ret

0000021e <writetab>:
}

/*******************************************************************/
/*                                                                 */
/*自定义字符写入CGRAM                                              */
/*                                                                 */
/*******************************************************************/
void  writetab(void)  
{  
 21e:	0f 93       	push	r16
 220:	1f 93       	push	r17
 222:	cf 93       	push	r28
    uchar i;
    lcd_wcmd(0x40,1);            //写CGRAM
 224:	61 e0       	ldi	r22, 0x01	; 1
 226:	80 e4       	ldi	r24, 0x40	; 64
 228:	ae df       	rcall	.-164    	; 0x186
 22a:	04 ea       	ldi	r16, 0xA4	; 164
 22c:	10 e0       	ldi	r17, 0x00	; 0
 22e:	c7 e0       	ldi	r28, 0x07	; 7
    for (i = 0; i< 8; i++)       
    lcd_wdat(mytab[i]);        
 230:	f8 01       	movw	r30, r16
 232:	81 91       	ld	r24, Z+
 234:	8f 01       	movw	r16, r30
 236:	e2 df       	rcall	.-60     	; 0x1fc
 238:	c1 50       	subi	r28, 0x01	; 1
 23a:	c7 ff       	sbrs	r28, 7
 23c:	f9 cf       	rjmp	.-14     	; 0x230
 23e:	cf 91       	pop	r28
 240:	1f 91       	pop	r17
 242:	0f 91       	pop	r16
 244:	08 95       	ret

00000246 <Ok_Menu>:
}

/*******************************************************************/
/*                                                                 */
/* DS18B20 OK 显示菜单                                             */
/*                                                                 */
/*******************************************************************/

⌨️ 快捷键说明

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