?? lcd1602pbpd.lis
字號:
0370 .dbline 0 ; func end
0370 5991 ld R21,y+
0372 4991 ld R20,y+
0374 0895 ret
.area data(ram, con, rel)
0000 _LCD1602Err::
0000 .blkb 1
.area idata
0000 00 .byte 0
.area data(ram, con, rel)
.area text(rom, con, rel)
; busySta -> R18
; busyCounter -> R16,R17
.even
0376 _busy::
0376 ; /*********************************************************************
0376 ; 微 雪 電 子 WaveShare http://www.waveShare.net
0376 ;
0376 ; 目 的: 建立LCD1602的4位數據模式操作庫
0376 ;
0376 ; 目標系統: 基于AVR單片機
0376 ;
0376 ; 應用軟件: ICCAVR
0376 ;
0376 ; 版 本: Version 1.0
0376 ;
0376 ; 圓版時間: 2004-08-25
0376 ;
0376 ; 開發人員: SEE
0376 ;
0376 ; 說 明: 若用于商業用途,請保留此段文字或注明代碼來源
0376 ;
0376 ; 深 圳 市 微 雪 電 子 有 限 公 司 保 留 所 有 的 版 權
0376 ; *********************************************************************/
0376 ;
0376 ; /*01010101010101010101010101010101010101010101010101010101010101010101
0376 ; ----------------------------------------------------------------------
0376 ; 版本更新記錄:
0376 ; 版 本: Version 1.1
0376 ; 圓版時間: 2005-03-25
0376 ;
0376 ; ----------------------------------------------------------------------
0376 ; 入口參數說明:
0376 ;
0376 ; // control port
0376 ; //#define SET_RS sbi(PORTB,5)
0376 ; //#define CLR_RS cbi(PORTB,5)
0376 ; //#define OUT_RS sbi(DDRB,5)
0376 ;
0376 ; //#define SET_RW sbi(PORTB,6)
0376 ; //#define CLR_RW cbi(PORTB,6)
0376 ; //#define OUT_RW sbi(DDRB,6)
0376 ;
0376 ; //#define SET_E sbi(PORTB,7)
0376 ; //#define CLR_E cbi(PORTB,7)
0376 ; //#define OUT_E sbi(DDRB,7)
0376 ;
0376 ; // data port
0376 ; //#define SET_D4 sbi(PORTD,4)
0376 ; //#define CLR_D4 cbi(PORTD,4)
0376 ; //#define OUT_D4 sbi(DDRD,4)
0376 ;
0376 ; //#define SET_D5 sbi(PORTD,5)
0376 ; //#define CLR_D5 cbi(PORTD,5)
0376 ; //#define OUT_D5 sbi(DDRD,5)
0376 ;
0376 ; //#define SET_D6 sbi(PORTD,6)
0376 ; //#define CLR_D6 cbi(PORTD,6)
0376 ; //#define OUT_D6 sbi(DDRD,6)
0376 ;
0376 ; //#define SET_D7 sbi(PORTD,7)
0376 ; //#define CLR_D7 cbi(PORTD,7)
0376 ; //#define OUT_D7 sbi(DDRD,7)
0376 ;
0376 ; // busy port
0376 ; //#define GET_BF gbi(PIND,7)
0376 ; //#define OUT_BF sbi(DDRD,7)
0376 ; //#define IN_BF cbi(DDRD,7)
0376 ;
0376 ; ----------------------------------------------------------------------
0376 ; 接口定義:
0376 ; LCD1602 ATmega16
0376 ; 1.GND -------- GND
0376 ; 2.VCC -------- VCC
0376 ; 3.V0 -------- V0
0376 ; 4.RS -------- 由外部程序定義
0376 ; 5.R/W -------- 由外部程序定義
0376 ; 6.E -------- 由外部程序定義
0376 ; 7.D0 -------- NC
0376 ; 8.D1 -------- NC
0376 ; 9.D2 -------- NC
0376 ; 10.D3 -------- NC
0376 ; 11.D4 -------- 由外部程序定義
0376 ; 12.D5 -------- 由外部程序定義
0376 ; 13.D6 -------- 由外部程序定義
0376 ; 14.D7 -------- 由外部程序定義
0376 ; 15.LED+ -------- VCC
0376 ; 16.LED- -------- GND
0376 ;
0376 ; 說明:
0376 ; (1)使用ATmega16的7根IO口操作LCD1602
0376 ; (2)該程序的優點是:7根IO可任意定義,不需分布在固定的一組PORT口上
0376 ; (3)該程序的缺點是:IO定義的寫法較為繁瑣
0376 ; ----------------------------------------------------------------------
0376 ; 待定參數說明:
0376 ; //#define DELAY() {_nop_();_nop_();_nop_();}
0376 ;
0376 ; ----------------------------------------------------------------------
0376 ; 對外變量說明:
0376 ;
0376 ; ----------------------------------------------------------------------
0376 ; 對外函數說明:
0376 ;
0376 ; ----------------------------------------------------------------------
0376 ; 10101010101010101010101010101010101010101010101010101010101010101010*/
0376 ;
0376 ; #ifndef LCD1602_H
0376 ; #define LCD1602_H
0376 ;
0376 ; #include "D:\ICC_H\CmmICC.H"
0376 ;
0376 ; /* 待定參數 */
0376 ; #define DELAY() {NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();}
0376 ;
0376 ; /* 不考慮移植性的寫法 */
0376 ; //uint8 bdata bdat;
0376 ; //sbit bdat0=bdat^0;
0376 ; //sbit bdat1=bdat^1;
0376 ; //sbit bdat2=bdat^2;
0376 ; //sbit bdat3=bdat^3;
0376 ; //sbit bdat4=bdat^4;
0376 ; //sbit bdat5=bdat^5;
0376 ; //sbit bdat6=bdat^6;
0376 ; //sbit bdat7=bdat^7;
0376 ; /* 考慮移植性的寫法 */
0376 ; uint8 bdat;
0376 ; #define bdat0 (bdat&0x01)
0376 ; #define bdat1 (bdat&0x02)
0376 ; #define bdat2 (bdat&0x04)
0376 ; #define bdat3 (bdat&0x08)
0376 ; #define bdat4 (bdat&0x10)
0376 ; #define bdat5 (bdat&0x20)
0376 ; #define bdat6 (bdat&0x40)
0376 ; #define bdat7 (bdat&0x80)
0376 ;
0376 ; #define CGRAM0 0x00
0376 ; #define CGRAM1 0x01
0376 ; #define CGRAM2 0x02
0376 ; #define CGRAM3 0x03
0376 ; #define CGRAM4 0x04
0376 ; #define CGRAM5 0x05
0376 ; #define CGRAM6 0x06
0376 ; #define CGRAM7 0x07
0376 ;
0376 ; #define TRUE 1
0376 ; #define FALSE 0
0376 ; bool LCD1602Err = FALSE;
0376 ;
0376 ; /*--------------------------------------------------------------------
0376 ; 函數名稱:LCD1602讀讀讀讀讀忙~
0376 ; 函數功能:都說是讀讀讀讀讀忙咯~
0376 ; 注意事項:對于高速CPU,應加延時,好像是廢話~
0376 ; 提示說明:無
0376 ; 輸 入:
0376 ; 返 回:無
0376 ; --------------------------------------------------------------------*/
0376 ; void busy(void)
0376 ; {
0376 ; uint16 busyCounter=0;
0376 0027 clr R16
0378 1127 clr R17
037A ; bool busySta; //用于探測 lcd busy status
037A ; IN_BF;
037A 8F98 cbi 0x11,7
037C ; SET_D4;
037C 949A sbi 0x12,4
037E ; SET_D5;
037E 959A sbi 0x12,5
0380 ; SET_D6;
0380 969A sbi 0x12,6
0382 ; SET_D7;
0382 979A sbi 0x12,7
0384 ; DELAY();
0384 0000 nop
0386 0000 nop
0388 0000 nop
038A 0000 nop
038C 0000 nop
038E 0000 nop
0390 0000 nop
0392 0000 nop
0394 ; CLR_RS;
0394 C598 cbi 0x18,5
0396 ; DELAY();
0396 0000 nop
0398 0000 nop
039A 0000 nop
039C 0000 nop
039E 0000 nop
03A0 0000 nop
03A2 0000 nop
03A4 0000 nop
03A6 ; SET_RW;
03A6 C69A sbi 0x18,6
03A8 ; DELAY();
03A8 0000 nop
03AA 0000 nop
03AC 0000 nop
03AE 0000 nop
03B0 0000 nop
03B2 0000 nop
03B4 0000 nop
03B6 0000 nop
03B8 L122:
03B8 ;
03B8 ; do
03B8 ; {
03B8 ; SET_E;
03B8 C79A sbi 0x18,7
03BA ; DELAY();
03BA 0000 nop
03BC 0000 nop
03BE 0000 nop
03C0 0000 nop
03C2 0000 nop
03C4 0000 nop
03C6 0000 nop
03C8 0000 nop
03CA ; /* 這里讀取AC4-AC6位及BF的值,程序不需記錄AC4-AC6的值,所以不存儲 */
03CA ; busySta=(bool)GET_BF;
03CA 20B3 in R18,0x10
03CC 3327 clr R19
03CE 2078 andi R18,128
03D0 3070 andi R19,0
03D2 ; CLR_E;
03D2 C798 cbi 0x18,7
03D4 ; DELAY();
03D4 0000 nop
03D6 0000 nop
03D8 0000 nop
03DA 0000 nop
03DC 0000 nop
03DE 0000 nop
03E0 0000 nop
03E2 0000 nop
03E4 ; /* 讀取 "BUSY"時,"D4-D7"狀態可能已經改變,必須再次設為輸出"1" */
03E4 ; SET_D4;
03E4 949A sbi 0x12,4
03E6 ; SET_D5;
03E6 959A sbi 0x12,5
03E8 ; SET_D6;
03E8 969A sbi 0x12,6
03EA ; SET_D7;
03EA 979A sbi 0x12,7
03EC ; DELAY();
03EC 0000 nop
03EE 0000 nop
03F0 0000 nop
03F2 0000 nop
03F4 0000 nop
03F6 0000 nop
03F8 0000 nop
03FA 0000 nop
03FC ; SET_E;
03FC C79A sbi 0x18,7
03FE ; DELAY();
03FE 0000 nop
0400 0000 nop
0402 0000 nop
0404 0000 nop
0406 0000 nop
0408 0000 nop
040A 0000 nop
040C 0000 nop
040E ; /* 這里讀取AC0-AC3位的值,程序不需記錄AC0-AC3的值,所以不存儲 */
040E ; CLR_E;
040E C798 cbi 0x18,7
0410 ; DELAY();
0410 0000 nop
0412 0000 nop
0414 0000 nop
0416 0000 nop
0418 0000 nop
041A 0000 nop
041C 0000 nop
041E 0000 nop
0420 ; if(busyCounter==1000)
0420 083E cpi R16,232
0422 E3E0 ldi R30,3
0424 1E07 cpc R17,R30
0426 21F4 brne L125
0428 X44:
0428 ; {
0428 ; LCD1602Err=TRUE; //標識LCD1602錯誤,方便上繳系統報錯
0428 81E0 ldi R24,1
042A 80930000 sts _LCD1602Err,R24
042E ; return ; //避免由于LCD1602錯誤而導致程序阻塞
042E 0AC0 xjmp L121
0430 L125:
0430 ; }
0430 ; busyCounter++;
0430 0F5F subi R16,255 ; offset = 1
0432 1F4F sbci R17,255
0434 ; }
0434 L123:
0434 ; while(busySta);
0434 2223 tst R18
0436 09F0 breq X46
0438 BFCF xjmp L122
043A X46:
043A X45:
043A ;
043A ; LCD1602Err=FALSE;
043A 2224 clr R2
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -