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

📄 main.lss

📁 用ATmega32写的采用四线接法的LCD1602驱动程序
💻 LSS
📖 第 1 页 / 共 3 页
字号:

00000152 <write_byte_to_LCD>:
* 调用          :NULL
* 编写日期      :2008-2-29 
* 最后修改日期  :2008-2-29 
*********************************************************/
void write_byte_to_LCD(uchar data,uchar dataOrCmd)
{
 152:	0f 93       	push	r16
 154:	1f 93       	push	r17
 156:	18 2f       	mov	r17, r24
 158:	06 2f       	mov	r16, r22
   //_delay_us(500);             //用延时代替读忙 
   read_busy();
 15a:	0e 94 73 00 	call	0xe6	; 0xe6 <read_busy>
   
   lcm_delay(20);
 15e:	80 e0       	ldi	r24, 0x00	; 0
 160:	90 e0       	ldi	r25, 0x00	; 0
 162:	01 c0       	rjmp	.+2      	; 0x166 <write_byte_to_LCD+0x14>
* 最后修改日期  :2008-2-29 
************************************************************************/
void lcm_delay(volatile unsigned long i)
{
  unsigned int a;
  for(a=0;a<i;a++)
 164:	01 96       	adiw	r24, 0x01	; 1
 166:	84 31       	cpi	r24, 0x14	; 20
 168:	91 05       	cpc	r25, r1
 16a:	e0 f3       	brcs	.-8      	; 0x164 <write_byte_to_LCD+0x12>
{
   //_delay_us(500);             //用延时代替读忙 
   read_busy();
   
   lcm_delay(20);
   if( data )
 16c:	11 23       	and	r17, r17
 16e:	11 f0       	breq	.+4      	; 0x174 <write_byte_to_LCD+0x22>
   {
     LCD_RS_PORT |= LCD_RS;     //RS=1,写数据
 170:	a9 9a       	sbi	0x15, 1	; 21
 172:	01 c0       	rjmp	.+2      	; 0x176 <write_byte_to_LCD+0x24>
   }
   else
   {
     LCD_RS_PORT &= ~LCD_RS;    //RS=0,写命令  
 174:	a9 98       	cbi	0x15, 1	; 21
   }
   lcm_delay(20);
 176:	80 e0       	ldi	r24, 0x00	; 0
 178:	90 e0       	ldi	r25, 0x00	; 0
 17a:	01 c0       	rjmp	.+2      	; 0x17e <write_byte_to_LCD+0x2c>
* 最后修改日期  :2008-2-29 
************************************************************************/
void lcm_delay(volatile unsigned long i)
{
  unsigned int a;
  for(a=0;a<i;a++)
 17c:	01 96       	adiw	r24, 0x01	; 1
 17e:	84 31       	cpi	r24, 0x14	; 20
 180:	91 05       	cpc	r25, r1
 182:	e0 f3       	brcs	.-8      	; 0x17c <write_byte_to_LCD+0x2a>
   else
   {
     LCD_RS_PORT &= ~LCD_RS;    //RS=0,写命令  
   }
   lcm_delay(20);
   LCD_EN_PORT &= ~LCD_EN;     //EN=0 
 184:	ab 98       	cbi	0x15, 3	; 21
   lcm_delay(20);  
 186:	80 e0       	ldi	r24, 0x00	; 0
 188:	90 e0       	ldi	r25, 0x00	; 0
 18a:	01 c0       	rjmp	.+2      	; 0x18e <write_byte_to_LCD+0x3c>
* 最后修改日期  :2008-2-29 
************************************************************************/
void lcm_delay(volatile unsigned long i)
{
  unsigned int a;
  for(a=0;a<i;a++)
 18c:	01 96       	adiw	r24, 0x01	; 1
 18e:	84 31       	cpi	r24, 0x14	; 20
 190:	91 05       	cpc	r25, r1
 192:	e0 f3       	brcs	.-8      	; 0x18c <write_byte_to_LCD+0x3a>
     LCD_RS_PORT &= ~LCD_RS;    //RS=0,写命令  
   }
   lcm_delay(20);
   LCD_EN_PORT &= ~LCD_EN;     //EN=0 
   lcm_delay(20);  
   LCD_RW_PORT &= ~LCD_RW;     //RW=0  
 194:	aa 98       	cbi	0x15, 2	; 21
   
   LCD_DDR |= 0xFF;
 196:	84 b3       	in	r24, 0x14	; 20
 198:	8f ef       	ldi	r24, 0xFF	; 255
 19a:	84 bb       	out	0x14, r24	; 20

   lcm_delay(20);
 19c:	80 e0       	ldi	r24, 0x00	; 0
 19e:	90 e0       	ldi	r25, 0x00	; 0
 1a0:	01 c0       	rjmp	.+2      	; 0x1a4 <write_byte_to_LCD+0x52>
* 最后修改日期  :2008-2-29 
************************************************************************/
void lcm_delay(volatile unsigned long i)
{
  unsigned int a;
  for(a=0;a<i;a++)
 1a2:	01 96       	adiw	r24, 0x01	; 1
 1a4:	84 31       	cpi	r24, 0x14	; 20
 1a6:	91 05       	cpc	r25, r1
 1a8:	e0 f3       	brcs	.-8      	; 0x1a2 <write_byte_to_LCD+0x50>
   LCD_RW_PORT &= ~LCD_RW;     //RW=0  
   
   LCD_DDR |= 0xFF;

   lcm_delay(20);
   LCD_DATA_PORT &= 0X0F;           //portc4~7=0,先清零数据口
 1aa:	85 b3       	in	r24, 0x15	; 21
 1ac:	8f 70       	andi	r24, 0x0F	; 15
 1ae:	85 bb       	out	0x15, r24	; 21
   LCD_DATA_PORT |= dataOrCmd&0xF0; //send high 4bit
 1b0:	95 b3       	in	r25, 0x15	; 21
 1b2:	80 2f       	mov	r24, r16
 1b4:	80 7f       	andi	r24, 0xF0	; 240
 1b6:	89 2b       	or	r24, r25
 1b8:	85 bb       	out	0x15, r24	; 21
   LCD_EN_PORT   |= LCD_EN;         //EN端产生一个由低电平变高电平,写LCD
 1ba:	ab 9a       	sbi	0x15, 3	; 21
 
   lcm_delay(20);
 1bc:	80 e0       	ldi	r24, 0x00	; 0
 1be:	90 e0       	ldi	r25, 0x00	; 0
 1c0:	01 c0       	rjmp	.+2      	; 0x1c4 <write_byte_to_LCD+0x72>
* 最后修改日期  :2008-2-29 
************************************************************************/
void lcm_delay(volatile unsigned long i)
{
  unsigned int a;
  for(a=0;a<i;a++)
 1c2:	01 96       	adiw	r24, 0x01	; 1
 1c4:	84 31       	cpi	r24, 0x14	; 20
 1c6:	91 05       	cpc	r25, r1
 1c8:	e0 f3       	brcs	.-8      	; 0x1c2 <write_byte_to_LCD+0x70>
   LCD_DATA_PORT &= 0X0F;           //portc4~7=0,先清零数据口
   LCD_DATA_PORT |= dataOrCmd&0xF0; //send high 4bit
   LCD_EN_PORT   |= LCD_EN;         //EN端产生一个由低电平变高电平,写LCD
 
   lcm_delay(20);
   LCD_EN_PORT   &= ~LCD_EN;        //EN端产生一个由高电平变低电平,为写低四位数据做准备
 1ca:	ab 98       	cbi	0x15, 3	; 21
   
   lcm_delay(20); 
 1cc:	80 e0       	ldi	r24, 0x00	; 0
 1ce:	90 e0       	ldi	r25, 0x00	; 0
 1d0:	01 c0       	rjmp	.+2      	; 0x1d4 <write_byte_to_LCD+0x82>
* 最后修改日期  :2008-2-29 
************************************************************************/
void lcm_delay(volatile unsigned long i)
{
  unsigned int a;
  for(a=0;a<i;a++)
 1d2:	01 96       	adiw	r24, 0x01	; 1
 1d4:	84 31       	cpi	r24, 0x14	; 20
 1d6:	91 05       	cpc	r25, r1
 1d8:	e0 f3       	brcs	.-8      	; 0x1d2 <write_byte_to_LCD+0x80>
 
   lcm_delay(20);
   LCD_EN_PORT   &= ~LCD_EN;        //EN端产生一个由高电平变低电平,为写低四位数据做准备
   
   lcm_delay(20); 
   LCD_DATA_PORT &= 0X0F;                //portc4~7=0,先清零数据口
 1da:	85 b3       	in	r24, 0x15	; 21
 1dc:	8f 70       	andi	r24, 0x0F	; 15
 1de:	85 bb       	out	0x15, r24	; 21
   LCD_DATA_PORT |= (dataOrCmd<<4)&0xF0; //send low 4bit
 1e0:	85 b3       	in	r24, 0x15	; 21
 1e2:	02 95       	swap	r16
 1e4:	00 7f       	andi	r16, 0xF0	; 240
 1e6:	80 2b       	or	r24, r16
 1e8:	85 bb       	out	0x15, r24	; 21
   LCD_EN_PORT   |= LCD_EN;              //EN端产生一个由低电平变高电平,写LCD
 1ea:	ab 9a       	sbi	0x15, 3	; 21
   LCD_EN_PORT   &= ~LCD_EN;             //关闭使能信号,以免写入错误数据
 1ec:	ab 98       	cbi	0x15, 3	; 21
}
 1ee:	1f 91       	pop	r17
 1f0:	0f 91       	pop	r16
 1f2:	08 95       	ret

000001f4 <init_LCD>:
* 调用          :void write_byte_to_LCD(uchar data,uchar dataOrCmd)
* 编写日期      :2008-2-29 
* 最后修改日期  :2008-2-29 
***************************************************************************/
void  init_LCD(void)
{
 1f4:	84 b3       	in	r24, 0x14	; 20
 1f6:	80 6f       	ori	r24, 0xF0	; 240
 1f8:	84 bb       	out	0x14, r24	; 20
* 最后修改日期  :2008-2-29 
************************************************************************/
void LCD_PORT_init(void)
{
  LCD_DATA_DDR |= LCD_DATA;
  LCD_CTR_DDR  |= LCD_RS | LCD_RW | LCD_EN;
 1fa:	84 b3       	in	r24, 0x14	; 20
 1fc:	8e 60       	ori	r24, 0x0E	; 14
 1fe:	84 bb       	out	0x14, r24	; 20
  LCD_EN_PORT  &= ~LCD_EN;      //EN=0
 200:	ab 98       	cbi	0x15, 3	; 21
***************************************************************************/
void  init_LCD(void)
{
  LCD_PORT_init();      //设定LCD接口为输出
  
  write_byte_to_LCD(0,0x28); //显示模式设置以后都查测忙信号,设置4总线共有16*2字,每字有5*10(5*7)点阵
 202:	68 e2       	ldi	r22, 0x28	; 40
 204:	80 e0       	ldi	r24, 0x00	; 0
 206:	0e 94 a9 00 	call	0x152	; 0x152 <write_byte_to_LCD>
  write_byte_to_LCD(0,0x01); //显示清屏
 20a:	61 e0       	ldi	r22, 0x01	; 1
 20c:	80 e0       	ldi	r24, 0x00	; 0
 20e:	0e 94 a9 00 	call	0x152	; 0x152 <write_byte_to_LCD>
  write_byte_to_LCD(0,0x02); //地址归位
 212:	62 e0       	ldi	r22, 0x02	; 2
 214:	80 e0       	ldi	r24, 0x00	; 0
 216:	0e 94 a9 00 	call	0x152	; 0x152 <write_byte_to_LCD>
  write_byte_to_LCD(0,0x0C); //显示关闭
 21a:	6c e0       	ldi	r22, 0x0C	; 12
 21c:	80 e0       	ldi	r24, 0x00	; 0
 21e:	0e 94 a9 00 	call	0x152	; 0x152 <write_byte_to_LCD>
  write_byte_to_LCD(0,0x14); //显示光标移动设置,光标移动,显示区不移动
 222:	64 e1       	ldi	r22, 0x14	; 20
 224:	80 e0       	ldi	r24, 0x00	; 0
 226:	0e 94 a9 00 	call	0x152	; 0x152 <write_byte_to_LCD>
}
 22a:	08 95       	ret

0000022c <LCD_set_xy>:
* 调用          :void write_byte_to_LCD(uchar data,uchar dataOrCmd)
* 编写日期      :2008-2-29 
* 最后修改日期  :2008-2-29
***************************************************************************/
void LCD_set_xy( unsigned char X, unsigned char Y )
{
 22c:	66 23       	and	r22, r22
 22e:	11 f4       	brne	.+4      	; 0x234 <LCD_set_xy+0x8>
  if ( Y == 0) 
  {
	write_byte_to_LCD(0,0x80+X);   
 230:	80 58       	subi	r24, 0x80	; 128
 232:	01 c0       	rjmp	.+2      	; 0x236 <LCD_set_xy+0xa>
  }
  else 
  {	  
    write_byte_to_LCD(0,0xC0+X); 	   
 234:	80 54       	subi	r24, 0x40	; 64
 236:	68 2f       	mov	r22, r24
 238:	80 e0       	ldi	r24, 0x00	; 0
 23a:	0e 94 a9 00 	call	0x152	; 0x152 <write_byte_to_LCD>
 23e:	08 95       	ret

00000240 <LCD_dis_char>:
                  void write_byte_to_LCD(uchar data,uchar dataOrCmd)
* 编写日期      :2008-2-29 
* 最后修改日期  :2008-2-29		
***************************************************************************/
void LCD_dis_char(uchar X,uchar Y,char data)
{
 240:	1f 93       	push	r17
 242:	98 2f       	mov	r25, r24
 244:	14 2f       	mov	r17, r20
  if (X>15)     //显示超出一行时进行处理
 246:	80 31       	cpi	r24, 0x10	; 16
 248:	18 f0       	brcs	.+6      	; 0x250 <LCD_dis_char+0x10>
  {
    Y ^= 0x01;  //换行显示
 24a:	81 e0       	ldi	r24, 0x01	; 1
 24c:	68 27       	eor	r22, r24
	X -= 16;
 24e:	90 51       	subi	r25, 0x10	; 16
  }
  LCD_set_xy( X, Y );
 250:	89 2f       	mov	r24, r25
 252:	0e 94 16 01 	call	0x22c	; 0x22c <LCD_set_xy>
  write_byte_to_LCD(1,data);
 256:	61 2f       	mov	r22, r17
 258:	81 e0       	ldi	r24, 0x01	; 1
 25a:	0e 94 a9 00 	call	0x152	; 0x152 <write_byte_to_LCD>
}
 25e:	1f 91       	pop	r17
 260:	08 95       	ret

00000262 <LCD_dis_string>:
                  void write_byte_to_LCD(uchar data,uchar dataOrCmd)
* 编写日期      :2008-2-29 
* 最后修改日期  :2008-2-29
***************************************************************************/
void LCD_dis_string(unsigned char X,unsigned char Y,char *s)
{ 
 262:	ff 92       	push	r15
 264:	0f 93       	push	r16
 266:	1f 93       	push	r17
 268:	cf 93       	push	r28
 26a:	df 93       	push	r29
 26c:	06 2f       	mov	r16, r22

⌨️ 快捷键说明

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