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

📄 2x8_key.lss

📁 WINAVR写的2x8键盘扫描程序
💻 LSS
📖 第 1 页 / 共 5 页
字号:
 4e4:	8d 83       	std	Y+5, r24	; 0x05
 4e6:	8d 81       	ldd	r24, Y+5	; 0x05
 4e8:	9e 81       	ldd	r25, Y+6	; 0x06
 4ea:	01 97       	sbiw	r24, 0x01	; 1
 4ec:	f1 f7       	brne	.-4      	; 0x4ea <__stack+0x8b>
 4ee:	9e 83       	std	Y+6, r25	; 0x06
 4f0:	8d 83       	std	Y+5, r24	; 0x05
	_delay_ms(5);
	LCM1602WriteCommand(0x38,0);
 4f2:	60 e0       	ldi	r22, 0x00	; 0
 4f4:	88 e3       	ldi	r24, 0x38	; 56
 4f6:	0e 94 10 03 	call	0x620 <LCM1602WriteCommand>
   The maximal possible delay is 262.14 ms / F_CPU in MHz.
 */
void
_delay_ms(double __ms)
{
 4fa:	80 e0       	ldi	r24, 0x00	; 0
 4fc:	90 e0       	ldi	r25, 0x00	; 0
 4fe:	a0 ea       	ldi	r26, 0xA0	; 160
 500:	b0 e4       	ldi	r27, 0x40	; 64
 502:	8f 83       	std	Y+7, r24	; 0x07
 504:	98 87       	std	Y+8, r25	; 0x08
 506:	a9 87       	std	Y+9, r26	; 0x09
 508:	ba 87       	std	Y+10, r27	; 0x0a
	uint16_t __ticks;
	double __tmp = ((F_CPU) / 4e3) * __ms;
 50a:	26 e6       	ldi	r18, 0x66	; 102
 50c:	36 e6       	ldi	r19, 0x66	; 102
 50e:	46 ee       	ldi	r20, 0xE6	; 230
 510:	54 e4       	ldi	r21, 0x44	; 68
 512:	6f 81       	ldd	r22, Y+7	; 0x07
 514:	78 85       	ldd	r23, Y+8	; 0x08
 516:	89 85       	ldd	r24, Y+9	; 0x09
 518:	9a 85       	ldd	r25, Y+10	; 0x0a
 51a:	0e 94 0e 07 	call	0xe1c <__mulsf3>
 51e:	dc 01       	movw	r26, r24
 520:	cb 01       	movw	r24, r22
 522:	89 83       	std	Y+1, r24	; 0x01
 524:	9a 83       	std	Y+2, r25	; 0x02
 526:	ab 83       	std	Y+3, r26	; 0x03
 528:	bc 83       	std	Y+4, r27	; 0x04
	if (__tmp < 1.0)
 52a:	20 e0       	ldi	r18, 0x00	; 0
 52c:	30 e0       	ldi	r19, 0x00	; 0
 52e:	40 e8       	ldi	r20, 0x80	; 128
 530:	5f e3       	ldi	r21, 0x3F	; 63
 532:	69 81       	ldd	r22, Y+1	; 0x01
 534:	7a 81       	ldd	r23, Y+2	; 0x02
 536:	8b 81       	ldd	r24, Y+3	; 0x03
 538:	9c 81       	ldd	r25, Y+4	; 0x04
 53a:	0e 94 be 06 	call	0xd7c <__eqsf2>
 53e:	88 23       	and	r24, r24
 540:	0c f0       	brlt	.+2      	; 0x544 <__stack+0xe5>
 542:	05 c0       	rjmp	.+10     	; 0x54e <__stack+0xef>
		__ticks = 1;
 544:	81 e0       	ldi	r24, 0x01	; 1
 546:	90 e0       	ldi	r25, 0x00	; 0
 548:	9c 87       	std	Y+12, r25	; 0x0c
 54a:	8b 87       	std	Y+11, r24	; 0x0b
 54c:	1a c0       	rjmp	.+52     	; 0x582 <__stack+0x123>
	else if (__tmp > 65535)
 54e:	20 e0       	ldi	r18, 0x00	; 0
 550:	3f ef       	ldi	r19, 0xFF	; 255
 552:	4f e7       	ldi	r20, 0x7F	; 127
 554:	57 e4       	ldi	r21, 0x47	; 71
 556:	69 81       	ldd	r22, Y+1	; 0x01
 558:	7a 81       	ldd	r23, Y+2	; 0x02
 55a:	8b 81       	ldd	r24, Y+3	; 0x03
 55c:	9c 81       	ldd	r25, Y+4	; 0x04
 55e:	0e 94 c1 06 	call	0xd82 <__gesf2>
 562:	18 16       	cp	r1, r24
 564:	0c f0       	brlt	.+2      	; 0x568 <__stack+0x109>
 566:	03 c0       	rjmp	.+6      	; 0x56e <__stack+0x10f>
		__ticks = 0;	/* i.e. 65536 */
 568:	1c 86       	std	Y+12, r1	; 0x0c
 56a:	1b 86       	std	Y+11, r1	; 0x0b
 56c:	0a c0       	rjmp	.+20     	; 0x582 <__stack+0x123>
	else
		__ticks = (uint16_t)__tmp;
 56e:	69 81       	ldd	r22, Y+1	; 0x01
 570:	7a 81       	ldd	r23, Y+2	; 0x02
 572:	8b 81       	ldd	r24, Y+3	; 0x03
 574:	9c 81       	ldd	r25, Y+4	; 0x04
 576:	0e 94 a3 06 	call	0xd46 <__fixsfsi>
 57a:	dc 01       	movw	r26, r24
 57c:	cb 01       	movw	r24, r22
 57e:	9c 87       	std	Y+12, r25	; 0x0c
 580:	8b 87       	std	Y+11, r24	; 0x0b
 582:	8b 85       	ldd	r24, Y+11	; 0x0b
 584:	9c 85       	ldd	r25, Y+12	; 0x0c
 586:	9e 83       	std	Y+6, r25	; 0x06
 588:	8d 83       	std	Y+5, r24	; 0x05
 58a:	8d 81       	ldd	r24, Y+5	; 0x05
 58c:	9e 81       	ldd	r25, Y+6	; 0x06
 58e:	01 97       	sbiw	r24, 0x01	; 1
 590:	f1 f7       	brne	.-4      	; 0x58e <__stack+0x12f>
 592:	9e 83       	std	Y+6, r25	; 0x06
 594:	8d 83       	std	Y+5, r24	; 0x05
	_delay_ms(5);
	LCM1602WriteCommand(0x38,1);         //以后的显示都要检查忙
 596:	61 e0       	ldi	r22, 0x01	; 1
 598:	88 e3       	ldi	r24, 0x38	; 56
 59a:	0e 94 10 03 	call	0x620 <LCM1602WriteCommand>
	LCM1602WriteCommand(0x08,1);         //关闭显示
 59e:	61 e0       	ldi	r22, 0x01	; 1
 5a0:	88 e0       	ldi	r24, 0x08	; 8
 5a2:	0e 94 10 03 	call	0x620 <LCM1602WriteCommand>
	LCM1602WriteCommand(0x01,1);         //显示清屏
 5a6:	61 e0       	ldi	r22, 0x01	; 1
 5a8:	81 e0       	ldi	r24, 0x01	; 1
 5aa:	0e 94 10 03 	call	0x620 <LCM1602WriteCommand>
	LCM1602WriteCommand(0x06,1);         //写指令06H,文字不动,光标自动右移
 5ae:	61 e0       	ldi	r22, 0x01	; 1
 5b0:	86 e0       	ldi	r24, 0x06	; 6
 5b2:	0e 94 10 03 	call	0x620 <LCM1602WriteCommand>
	LCM1602WriteCommand(0x0C,1);         //写指令0CH,显示ON,光标OFF,闪烁OFF
 5b6:	61 e0       	ldi	r22, 0x01	; 1
 5b8:	8c e0       	ldi	r24, 0x0C	; 12
 5ba:	0e 94 10 03 	call	0x620 <LCM1602WriteCommand>
 5be:	2c 96       	adiw	r28, 0x0c	; 12
 5c0:	0f b6       	in	r0, 0x3f	; 63
 5c2:	f8 94       	cli
 5c4:	de bf       	out	0x3e, r29	; 62
 5c6:	0f be       	out	0x3f, r0	; 63
 5c8:	cd bf       	out	0x3d, r28	; 61
 5ca:	df 91       	pop	r29
 5cc:	cf 91       	pop	r28
 5ce:	08 95       	ret

000005d0 <LCM1602BusyWait>:
}


//1602总线忙等待
void LCM1602BusyWait(void)
{
 5d0:	cf 93       	push	r28
 5d2:	df 93       	push	r29
 5d4:	cd b7       	in	r28, 0x3d	; 61
 5d6:	de b7       	in	r29, 0x3e	; 62
	DB_IN;                              //PB定义为输入,读引脚信号
 5d8:	10 92 37 00 	sts	0x0037, r1
	RS_CLR;
 5dc:	80 91 32 00 	lds	r24, 0x0032
 5e0:	8f 7e       	andi	r24, 0xEF	; 239
 5e2:	80 93 32 00 	sts	0x0032, r24
	RW_SET;                             //当RS为低电平RW为高电平时可以读忙信号
 5e6:	80 91 32 00 	lds	r24, 0x0032
 5ea:	80 62       	ori	r24, 0x20	; 32
 5ec:	80 93 32 00 	sts	0x0032, r24
	E_SET;
 5f0:	80 91 32 00 	lds	r24, 0x0032
 5f4:	80 68       	ori	r24, 0x80	; 128
 5f6:	80 93 32 00 	sts	0x0032, r24
	asm("nop\n nop");                  //延时两个nop时间
 5fa:	00 00       	nop
 5fc:	00 00       	nop
	while(DB_READ&0x80);              //直到忙信号结束,1602可再次写入信号
 5fe:	80 91 36 00 	lds	r24, 0x0036
 602:	88 23       	and	r24, r24
 604:	0c f4       	brge	.+2      	; 0x608 <LCM1602BusyWait+0x38>
 606:	fb cf       	rjmp	.-10     	; 0x5fe <LCM1602BusyWait+0x2e>
	DB_OUT;
 608:	8f ef       	ldi	r24, 0xFF	; 255
 60a:	80 93 37 00 	sts	0x0037, r24
	E_CLR;
 60e:	9f e7       	ldi	r25, 0x7F	; 127
 610:	80 91 32 00 	lds	r24, 0x0032
 614:	89 23       	and	r24, r25
 616:	80 93 32 00 	sts	0x0032, r24
 61a:	df 91       	pop	r29
 61c:	cf 91       	pop	r28
 61e:	08 95       	ret

00000620 <LCM1602WriteCommand>:
}


//向1602写入命令
void LCM1602WriteCommand(uchar com,uchar Busy)//Busy为0时忽略忙检测,为1时检查
{
 620:	cf 93       	push	r28
 622:	df 93       	push	r29
 624:	cd b7       	in	r28, 0x3d	; 61
 626:	de b7       	in	r29, 0x3e	; 62
 628:	22 97       	sbiw	r28, 0x02	; 2
 62a:	0f b6       	in	r0, 0x3f	; 63
 62c:	f8 94       	cli
 62e:	de bf       	out	0x3e, r29	; 62
 630:	0f be       	out	0x3f, r0	; 63
 632:	cd bf       	out	0x3d, r28	; 61
 634:	89 83       	std	Y+1, r24	; 0x01
 636:	6a 83       	std	Y+2, r22	; 0x02
	if(Busy)
 638:	8a 81       	ldd	r24, Y+2	; 0x02
 63a:	88 23       	and	r24, r24
 63c:	11 f0       	breq	.+4      	; 0x642 <LCM1602WriteCommand+0x22>
	{
		LCM1602BusyWait();                 //根据需要检测忙
 63e:	0e 94 e8 02 	call	0x5d0 <LCM1602BusyWait>
	}
	RS_CLR;    
 642:	80 91 32 00 	lds	r24, 0x0032
 646:	8f 7e       	andi	r24, 0xEF	; 239
 648:	80 93 32 00 	sts	0x0032, r24
	RW_CLR;                              //当RS和RW共同为低电平时可以写入指令或者显示地址
 64c:	80 91 32 00 	lds	r24, 0x0032
 650:	8f 7d       	andi	r24, 0xDF	; 223
 652:	80 93 32 00 	sts	0x0032, r24
	DB_PORT=com;
 656:	89 81       	ldd	r24, Y+1	; 0x01
 658:	80 93 38 00 	sts	0x0038, r24
	E_SET;
 65c:	80 91 32 00 	lds	r24, 0x0032
 660:	80 68       	ori	r24, 0x80	; 128
 662:	80 93 32 00 	sts	0x0032, r24
	E_CLR;
 666:	9f e7       	ldi	r25, 0x7F	; 127
 668:	80 91 32 00 	lds	r24, 0x0032
 66c:	89 23       	and	r24, r25
 66e:	80 93 32 00 	sts	0x0032, r24
 672:	22 96       	adiw	r28, 0x02	; 2
 674:	0f b6       	in	r0, 0x3f	; 63
 676:	f8 94       	cli
 678:	de bf       	out	0x3e, r29	; 62
 67a:	0f be       	out	0x3f, r0	; 63
 67c:	cd bf       	out	0x3d, r28	; 61
 67e:	df 91       	pop	r29
 680:	cf 91       	pop	r28
 682:	08 95       	ret

00000684 <LCM1602WriteData>:
}

//向1602写入数据
void LCM1602WriteData(uchar dat)
{
 684:	cf 93       	push	r28
 686:	df 93       	push	r29
 688:	cd b7       	in	r28, 0x3d	; 61
 68a:	de b7       	in	r29, 0x3e	; 62
 68c:	21 97       	sbiw	r28, 0x01	; 1
 68e:	0f b6       	in	r0, 0x3f	; 63
 690:	f8 94       	cli
 692:	de bf       	out	0x3e, r29	; 62
 694:	0f be       	out	0x3f, r0	; 63
 696:	cd bf       	out	0x3d, r28	; 61
 698:	89 83       	std	Y+1, r24	; 0x01
	LCM1602BusyWait();
 69a:	0e 94 e8 02 	call	0x5d0 <LCM1602BusyWait>
	RS_SET;   
 69e:	80 91 32 00 	lds	r24, 0x0032
 6a2:	80 61       	ori	r24, 0x10	; 16
 6a4:	80 93 32 00 	sts	0x0032, r24
	RW_CLR;                             //当RS为高电平RW为低电平时可以写入数据
 6a8:	80 91 32 00 	lds	r24, 0x0032
 6ac:	8f 7d       	andi	r24, 0xDF	; 223
 6ae:	80 93 32 00 	sts	0x0032, r24
	DB_PORT=dat;
 6b2:	89 81       	ldd	r24, Y+1	; 0x01
 6b4:	80 93 38 00 	sts	0x0038, r24
	E_SET;
 6b8:	80 91 32 00 	lds	r24, 0x0032
 6bc:	80 68       	ori	r24, 0x80	; 128
 6be:	80 93 32 00 	sts	0x0032, r24
	E_CLR;
 6c2:	9f e7       	ldi	r25, 0x7F	; 127
 6c4:	80 91 32 00 	lds	r24, 0x0032
 6c8:	89 23       	and	r24, r25
 6ca:	80 93 32 00 	sts	0x0032, r24
 6ce:	21 96       	adiw	r28, 0x01	; 1
 6d0:	0f b6       	in	r0, 0x3f	; 63
 6d2:	f8 94       	cli
 6d4:	de bf       	out	0x3e, r29	; 62
 6d6:	0f be       	out	0x3f, r0	; 63
 6d8:	cd bf       	out	0x3d, r28	; 61
 6da:	df 91       	pop	r29
 6dc:	cf 91       	pop	r28
 6de:	08 95       	ret

000006e0 <LCD_set_xy>:
}


/*-----------------------------------------------------------------------
LCD_set_xy        : 设置LCD显示的起始位置
输入参数x、y      : 显示字符串的位置,X:0-15,Y:0-1
                    LCD第一行显示寄存器地址:0X80-0X8F
                    LCD第一行显示寄存器地址:0XC0-0XCF
-----------------------------------------------------------------------*/
void LCD_set_xy(uchar x,uchar y ) 
{
 6e0:	cf 93       	push	r28
 6e2:	df 93       	push	r29
 6e4:	cd b7       	in	r28, 0x3d	; 61
 6e6:	de b7       	in	r29, 0x3e	; 62
 6e8:	23 97       	sbiw	r28, 0x03	; 3
 6ea:	0f b6       	in	r0, 0x3f	; 63
 6ec:	f8 94       	cli
 6ee:	de bf       	out	0x3e, r29	; 62
 6f0:	0f be       	out	0x3f, r0	; 63
 6f2:	cd bf       	out	0x3d, r28	; 61
 6f4:	89 83       	std	Y+1, r24	; 0x01
 6f6:	6a 83       	std	Y+2, r22	; 0x02
    uchar address;
    if (y == 0) address = 0x80 + x;  //第一行
 6f8:	8a 81       	ldd	r24, Y+2	; 0x02
 6fa:	88 23       	and	r24, r24
 6fc:	29 f4       	brne	.+10     	; 0x708 <LCD_set_xy+0x28>
 6fe:	80 e8       	ldi	r24, 0x80	; 128
 700:	99 81       	ldd	r25, Y+1	; 0x01
 702:	89 0f       	add	r24, r25
 704:	8b 83       	std	Y+3, r24	; 0x03
 706:	04 c0       	rjmp	.+8      	; 0x710 <LCD_set_xy+0x30>
    else   address = 0xc0 + x;       //第二行
 708:	80 ec       	ldi	r24, 0xC0	; 192
 70a:	99 81       	ldd	r25, Y+1	; 0x01
 70c:	89 0f       	add	r24, r25
 70e:	8b 83       	std	Y+3, r24	; 0x03
    LCM1602WriteCommand(address,1);
 710:	61 e0       	ldi	r22, 0x01	; 1
 712:	8b 81       	ldd	r24, Y+3	; 0x03
 714:	0e 94 10 03 	call	0x620 <LCM1602WriteCommand>
 718:	23 96       	adiw	r28, 0x03	; 3
 71a:	0f b6       	in	r0, 0x3f	; 63
 71c:	f8 94       	cli
 71e:	de bf       	out	0x3e, r29	; 62
 720:	0f be       	out	0x3f, r0	; 63
 722:	cd bf       	out	0x3d, r28	; 61
 724:	df 91       	pop	r29
 726:	cf 91       	pop	r28
 728:	08 95       	ret

0000072a <LCM1602Write_String>:
}


//英文字符串显示函数
void LCM1602Write_String(uchar x,uchar y,char *string)
{
 72a:	cf 93       	push	r28
 72c:	df 93       	push	r29
 72e:	cd b7       	in	r28, 0x3d	; 61
 730:	de b7       	in	r29, 0x3e	; 62
 732:	24 97       	sbiw	r28, 0x04	; 4
 734:	0f b6       	in	r0, 0x3f	; 63
 736:	f8 94       	cli
 738:	de bf       	out	0x3e, r29	; 62
 73a:	0f be       	out	0x3f, r0	; 63
 73c:	cd bf       	out	0x3d, r28	; 61
 73e:	89 83       	std	Y+1, r24	; 0x01
 740:	6a 83       	std	Y+2, r22	; 0x02
 742:	5c 83       	std	Y+4, r21	; 0x04
 744:	4b 83       	std	Y+3, r20	; 0x03
	if(x>=XSIZE||y>=YSIZE||string==NULL)return;
 746:	89 81       	ldd	r24, Y+1	; 0x01
 748:	80 31       	cpi	r24, 0x10	; 16
 74a:	18 f5       	brcc	.+70     	; 0x792 <LCM1602Write_String+0x68>
 74c:	8a 81       	ldd	r24, Y+2	; 0x02
 74e:	82 30       	cpi	r24, 0x02	; 2
 750:	00 f5       	brcc	.+64     	; 0x792 <LCM1602Write_String+0x68>
 752:	8b 81       	ldd	r24, Y+3	; 0x03
 754:	9c 81       	ldd	r25, Y+4	; 0x04
 756:	00 97       	sbiw	r24, 0x00	; 0
 758:	09 f4       	brne	.+2      	; 0x75c <LCM1602Write_String+0x32>
 75a:	1b c0       	rjmp	.+54     	; 0x792 <LCM1602Write_String+0x68>

⌨️ 快捷键说明

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