[ บทความ : ตัวอย่างสำหรับ CP-SB31 V2 ตอนที่ 10 ] ทดสอบติดต่อกับ LCD กราฟิกส์ ด้วย CP-SB31V2

ตัวอย่างซอร์สโค้ดสำหรับติดต่อกับ LCD แบบกราฟิกส์ กับบอร์ด CP-SB31V2 ที่ติดตั้ง ET-DEBUG31 เป็นดังนี้



;/*****************************************/;
;/* Demo Program For Graphic LCD DV-12864 */;
;/* Hardware  : ET-CPSB31 V2.0            */;
;/* Complier  : Cross-32  V2.0            */;
;/* Function  : Show OscilloScope Picture */;
;/*****************************************/;
;

;/***************************************/;
;/* Equate List Port I/O ET-CPSB31 V2.0 */;
;/***************************************/;
;
WR_COMM1   EQU     0E0C4H                  ; Write Instruction Page1
RD_COMM1   EQU     0E0C5H                  ; Reda Busy flag & Address Page1
WR_DATA1   EQU     0E0C6H                  ; Write Data Page1
RD_DATA1   EQU     0E0C7H                  ; Read Data Page1
;
WR_COMM2   EQU     0E0C8H                  ; Write Instruction Page2
RD_COMM2   EQU     0E0C9H                  ; Reda Busy flag & Address Page2
WR_DATA2   EQU     0E0CAH                  ; Write Data Page2
RD_DATA2   EQU     0E0CBH                  ; Read Data Page2

            ORG     22H                     ; Start CPU-RAM Buffer
X_ADDR1:    DS     1                       ; X-Address1 Buffer
X_ADDR2:    DS     1                       ; X-Address2 Buffer
Y_ADDR1:    DS     1                       ; Y-Address1 Buffer
Y_ADDR2:    DS     1                       ; Y-Address2 Buffer
LINE_CNT:   DS     1                       ; Line LCD Counter
POST_CNT:   DS     1                       ; Write LCD Position Counter

            ORG     2200H                   ; Strat Program For "ET-DEBUG31"

MAIN:       MOV     R2,#02H                 ; Power-on Delay
PWR_DLY1:   MOV     R3,#00H
PWR_DLY2:   MOV     R4,#00H
            DJNZ    R4,$
            DJNZ    R3,PWR_DLY2
            DJNZ    R2,PWR_DLY1
            ;
            LCALL   INITGLCD                ; Initial Graphic LCD
            MOV     LINE_CNT,#8             ; Counter Line
            MOV     DPTR,#TAB_SCOPE         ; Table Picture Oscillo Scope
            ;
NEW_LINE:   LCALL   SET_X1                  ; Set X_Address Page1
            LCALL   SET_Y1                  ; Set Y_Address Page1
            MOV     POST_CNT,#64            ; Counter Y Position Page1
WR_PAGE1:   LCALL   BUSY_LCD1
            CLR     A
            MOVC    A,@A+DPTR               ; Get Data-Font
            PUSH    DPH
            PUSH    DPL
            MOV     DPTR,#WR_DATA1          ; Write Data Page1
            MOVX    @DPTR,A
            POP     DPL
            POP     DPH
            INC     DPTR
            DJNZ    POST_CNT,WR_PAGE1
            ;
            LCALL   SET_X2                  ; Set X_Address Page2
            LCALL   SET_Y2                  ; Set Y_Address Page2
            MOV     POST_CNT,#64            ; Counter Y Position Page2
WR_PAGE2:   LCALL   BUSY_LCD2
            CLR     A
            MOVC    A,@A+DPTR               ; Get Data-Font
            PUSH    DPH
            PUSH    DPL
            MOV     DPTR,#WR_DATA2          ; Write Data Page2
            MOVX    @DPTR,A
            POP     DPL
            POP     DPH
            INC     DPTR
            DJNZ    POST_CNT,WR_PAGE2
            ;
            INC     X_ADDR1                 ; Next Line Page1
            INC     X_ADDR2                 ; Next Line Page2
            DJNZ    LINE_CNT,NEW_LINE
            SJMP    $

;/***********************/;
;/* Initial Graphic LCD */;
;/***********************/;
;
INITGLCD:   LCALL   BUSY_LCD1               ; Wait LCD Busy
            MOV     DPTR,#WR_COMM1          ; Write Instruction1
            MOV     A,#3FH                  ; Display on-off1  X=1 ON,X=0 OFF
            MOVX    @DPTR,A
            ;
            LCALL   BUSY_LCD2               ; Wait LCD Busy
            MOV     DPTR,#WR_COMM2          ; Write Instruction2
            MOV     A,#3FH                  ; Display on-off2  X=1 ON,X=0 OFF
            MOVX    @DPTR,A
            ;
            LCALL   BUSY_LCD1               ; Wait LCD Busy
            MOV     DPTR,#WR_COMM1          ; Write Instruction1
            MOV     A,#0C0H                 ; Display Strat Page1
            MOVX    @DPTR,A
            ;
            LCALL   BUSY_LCD2               ; Wait LCD Busy
            MOV     DPTR,#WR_COMM2          ; Write Instruction2
            MOV     A,#0C0H                 ; Display Strat Page2
            MOVX    @DPTR,A
            ;
            CLR     A
            MOV     X_ADDR1,A               ; Start X-Address1 = 0
            MOV     X_ADDR2,A               ; Start X-Address2 = 0
            MOV     Y_ADDR1,A               ; Start Y-Address1 = 0
            MOV     Y_ADDR2,A               ; Start Y-Address2 = 0
            RET

;/*******************/;
;/* Set X-Address1  */;
;/* Input : X_ADDR1 */;
;/*       : (0..7)  */;
;/*******************/;
;
SET_X1:     PUSH    ACC
            LCALL   BUSY_LCD1               ; Wait LCD busy
            MOV     A,X_ADDR1
            ANL     A,#07H
            ORL     A,#0B8H
            PUSH    DPH
            PUSH    DPL
            MOV     DPTR,#WR_COMM1          ; Set X-Address Page1
            MOVX    @DPTR,A
            POP     DPL
            POP     DPH
            POP     ACC
            RET

;/*******************/;
;/* Set X-Address2  */;
;/* Input : X_ADDR2 */;
;/*       : (0..7)  */;
;/*******************/;
;
SET_X2:     PUSH    ACC
            LCALL   BUSY_LCD2               ; Wait LCD busy
            MOV     A,X_ADDR2
            ANL     A,#07H
            ORL     A,#0B8H
            PUSH    DPH
            PUSH    DPL
            MOV     DPTR,#WR_COMM2          ; Set X-Address Page2
            MOVX    @DPTR,A
            POP     DPL
            POP     DPH
            POP     ACC
            RET

;/*******************/;
;/* Set Y-Address1  */;
;/* Input : Y_ADDR1 */;
;/*       : (0..63) */;
;/*******************/;
;
SET_Y1:     PUSH    ACC
            LCALL   BUSY_LCD1       ; Wait LCD busy
            MOV     A,Y_ADDR1
            ANL     A,#63
            ORL     A,#40H
            PUSH    DPH
            PUSH    DPL
            MOV     DPTR,#WR_COMM1          ; Set Y-Address Page1
            MOVX    @DPTR,A
            POP     DPL
            POP     DPH
            POP     ACC
            RET

;/*******************/;
;/* Set Y-Address2  */;
;/* Input : Y_ADDR2 */;
;/*       : (0..63) */;
;/*******************/;
;
SET_Y2:     PUSH    ACC
            LCALL   BUSY_LCD2       ; Wait LCD busy
            MOV     A,Y_ADDR2
            ANL     A,#63
            ORL     A,#40H
            PUSH    DPH
            PUSH    DPL
            MOV     DPTR,#WR_COMM2          ; Set Y-Address Page2
            MOVX    @DPTR,A
            POP     DPL
            POP     DPH
            POP     ACC
            RET

;/***********************/;
;/* Read Busy Flag LCD1 */;
;/***********************/;
;
BUSY_LCD1:  PUSH    DPL
            PUSH    DPH
            PUSH    ACC
            MOV     DPTR,#RD_COMM1
BUSY1:      MOVX    A,@DPTR
            JB      ACC.7,BUSY1
            POP     ACC
            POP     DPH
            POP     DPL
            RET

;/***********************/;
;/* Read Busy Flag LCD2 */;
;/***********************/;
;
BUSY_LCD2:  PUSH    DPL
            PUSH    DPH
            PUSH    ACC
            MOV     DPTR,#RD_COMM2
BUSY2:      MOVX    A,@DPTR
            JB      ACC.7,BUSY2
            POP     ACC
            POP     DPH
            POP     DPL
            RET

;/*******************************/;
;/* Demo Picture OPscillo Scope */;
;/*******************************/;
;
TAB_SCOPE:  DB      0FFH,0FFH,007H,00BH,0F3H,013H,013H,013H
            DB      013H,013H,013H,013H,013H,013H,013H,013H
            DB      013H,013H,013H,013H,013H,013H,013H,013H
            DB      013H,013H,013H,013H,013H,013H,013H,013H
            DB      013H,013H,013H,013H,013H,013H,013H,013H
            DB      013H,013H,013H,013H,013H,013H,013H,013H
            DB      013H,013H,013H,013H,013H,013H,013H,013H
            DB      013H,013H,013H,013H,013H,013H,013H,013H
            DB      013H,013H,013H,013H,013H,013H,013H,013H
            DB      013H,013H,013H,013H,013H,013H,013H,013H
            DB      013H,013H,013H,013H,013H,013H,013H,013H
            DB      013H,013H,013H,0F3H,00BH,007H,0FFH,0FFH
            DB      003H,003H,003H,003H,003H,003H,003H,003H
            DB      003H,003H,043H,083H,003H,003H,003H,0E3H
            DB      003H,003H,083H,043H,003H,003H,003H,003H
            DB      003H,003H,003H,003H,003H,003H,0FFH,0FFH
LINE2:      DB      0FFH,0FFH,000H,000H,0FFH,000H,000H,000H
            DB      000H,080H,060H,018H,004H,002H,001H,001H
            DB      001H,002H,004H,018H,060H,080H,000H,000H
            DB      000H,000H,000H,000H,000H,080H,060H,018H
            DB      004H,002H,001H,001H,001H,002H,004H,018H
            DB      060H,080H,000H,000H,000H,000H,000H,000H
            DB      000H,080H,060H,018H,004H,002H,001H,001H
            DB      001H,002H,004H,018H,060H,080H,000H,000H
            DB      000H,000H,000H,000H,000H,080H,060H,018H
            DB      004H,002H,001H,001H,001H,002H,004H,018H
            DB      060H,080H,000H,000H,000H,000H,000H,000H
            DB      000H,080H,060H,0FFH,000H,000H,0FFH,0FFH
            DB      000H,000H,000H,000H,000H,044H,048H,071H
            DB      01AH,00CH,004H,002H,002H,0E1H,011H,051H
            DB      011H,0E2H,002H,004H,00CH,01AH,071H,048H
            DB      044H,000H,000H,000H,000H,000H,0FFH,0FFH
LINE3:      DB      0FFH,0FFH,000H,000H,0FFH,008H,008H,004H
            DB      002H,001H,080H,000H,000H,000H,000H,000H
            DB      000H,000H,000H,000H,080H,001H,002H,004H
            DB      008H,008H,008H,004H,002H,001H,080H,000H
            DB      000H,000H,000H,000H,000H,000H,000H,000H
            DB      080H,001H,002H,004H,008H,008H,008H,004H
            DB      002H,001H,080H,000H,000H,000H,000H,000H
            DB      000H,000H,000H,000H,080H,001H,002H,004H
            DB      008H,008H,008H,004H,002H,001H,080H,000H
            DB      000H,000H,000H,000H,000H,000H,000H,000H
            DB      080H,001H,002H,004H,008H,008H,008H,004H
            DB      002H,001H,080H,0FFH,000H,000H,0FFH,0FFH
            DB      000H,000H,000H,000H,000H,000H,000H,040H
            DB      080H,000H,010H,0A0H,080H,040H,041H,079H
            DB      041H,080H,0A0H,010H,000H,080H,040H,000H
            DB      000H,000H,000H,000H,000H,000H,0FFH,0FFH
LINE4:      DB      0FFH,0FFH,000H,000H,0FFH,001H,001H,001H
            DB      001H,001H,0E3H,021H,021H,021H,021H,021H
            DB      021H,021H,021H,021H,0E3H,001H,001H,001H
            DB      001H,001H,001H,001H,001H,001H,0E3H,021H
            DB      021H,021H,021H,021H,021H,021H,021H,021H
            DB      0E3H,001H,001H,001H,001H,001H,001H,001H
            DB      001H,001H,0E3H,021H,021H,021H,021H,021H
            DB      021H,021H,021H,021H,0E3H,001H,001H,001H
            DB      001H,001H,001H,001H,001H,001H,0E3H,021H
            DB      021H,021H,021H,021H,021H,021H,021H,021H
            DB      0E3H,001H,001H,001H,001H,001H,001H,001H
            DB      001H,001H,0E3H,0FFH,000H,000H,0FFH,0FFH
            DB      000H,000H,000H,000H,000H,011H,012H,01CH
            DB      006H,003H,001H,000H,000H,038H,044H,054H
            DB      044H,038H,000H,001H,003H,006H,01CH,012H
            DB      011H,000H,000H,000H,000H,000H,0FFH,0FFH
LINE5:      DB      0FFH,0FFH,000H,000H,0FFH,008H,008H,008H
            DB      008H,008H,00FH,000H,000H,000H,000H,000H
            DB      000H,000H,000H,000H,00FH,008H,008H,008H
            DB      008H,008H,008H,008H,008H,008H,00FH,000H
            DB      000H,000H,000H,000H,000H,000H,000H,000H
            DB      00FH,008H,008H,008H,008H,008H,008H,008H
            DB      008H,008H,00FH,000H,000H,000H,000H,000H
            DB      000H,000H,000H,000H,00FH,008H,008H,008H
            DB      008H,008H,008H,008H,008H,008H,00FH,000H
            DB      000H,000H,000H,000H,000H,000H,000H,000H
            DB      00FH,008H,008H,008H,008H,008H,008H,008H
            DB      008H,008H,00FH,0FFH,000H,000H,0FFH,0FFH
            DB      000H,000H,000H,000H,000H,070H,088H,0A8H
            DB      088H,070H,000H,000H,000H,000H,000H,000H
            DB      000H,000H,000H,000H,070H,088H,0A8H,088H
            DB      070H,000H,000H,000H,000H,000H,0FFH,0FFH
LINE6:      DB      0FFH,0FFH,038H,034H,033H,032H,032H,032H
            DB      032H,032H,032H,032H,032H,032H,032H,032H
            DB      032H,032H,032H,032H,032H,032H,032H,032H
            DB      032H,032H,032H,032H,032H,032H,032H,032H
            DB      032H,032H,032H,032H,032H,032H,032H,032H
            DB      032H,032H,032H,032H,032H,032H,032H,032H
            DB      032H,032H,032H,032H,032H,032H,032H,032H
            DB      032H,032H,032H,032H,032H,032H,032H,032H
            DB      032H,032H,032H,032H,032H,032H,032H,032H
            DB      032H,032H,032H,032H,032H,032H,032H,032H
            DB      032H,032H,032H,032H,032H,032H,032H,0F2H
            DB      0F2H,032H,032H,033H,034H,038H,03FH,03FH
            DB      030H,030H,030H,030H,030H,030H,030H,030H
            DB      030H,030H,030H,030H,030H,030H,030H,030H
            DB      030H,030H,030H,030H,030H,030H,030H,030H
            DB      030H,030H,030H,030H,030H,030H,0FFH,0FFH
LINE7:      DB      0FFH,0FFH,000H,000H,000H,000H,000H,040H
            DB      020H,020H,020H,0C0H,000H,040H,020H,020H
            DB      020H,0C0H,000H,040H,020H,0A0H,030H,02AH
            DB      0C6H,000H,048H,0ACH,04AH,022H,0C4H,048H
            DB      0A0H,014H,00CH,040H,020H,0A0H,020H,024H
            DB      0C6H,006H,00AH,0F2H,002H,004H,044H,024H
            DB      0A0H,020H,020H,0C0H,000H,040H,020H,0A0H
            DB      030H,02AH,0C6H,000H,004H,006H,006H,00AH
            DB      0F2H,002H,004H,0C4H,024H,0A0H,0A0H,020H
            DB      0C0H,000H,000H,040H,020H,0C0H,000H,000H
            DB      0FCH,000H,000H,000H,000H,000H,000H,0FFH
            DB      0FFH,000H,000H,000H,000H,000H,000H,0E0H
            DB      010H,0C8H,0E8H,0E8H,0C8H,010H,0E0H,000H
            DB      000H,000H,000H,000H,000H,000H,000H,000H
            DB      0E0H,010H,0C8H,0E8H,0E8H,0C8H,010H,0E0H
            DB      000H,000H,000H,000H,000H,000H,0FFH,0FFH
LINE8:      DB      0FFH,0FFH,0C0H,0C0H,0C0H,0C0H,0C0H,0C3H
            DB      0C5H,0C4H,0C4H,0C3H,0C0H,0C3H,0C5H,0C4H
            DB      0C4H,0C3H,0C0H,0C0H,0C3H,0C4H,0C1H,0C2H
            DB      0C7H,0C0H,0C0H,0C0H,0C0H,0C3H,0C4H,0C4H
            DB      0C3H,0C0H,0C0H,0C0H,0C3H,0C4H,0C1H,0C2H
            DB      0C7H,0C0H,0C0H,0C3H,0C4H,0C0H,0C0H,0C3H
            DB      0C4H,0C1H,0C2H,0C7H,0C0H,0C0H,0C3H,0C4H
            DB      0C1H,0C2H,0C7H,0C0H,0C0H,0C0H,0C0H,0C0H
            DB      0C3H,0C4H,0C0H,0C7H,0C1H,0C0H,0C0H,0C0H
            DB      0C7H,0C0H,0C0H,0C2H,0C5H,0C4H,0C4H,0C4H
            DB      0C3H,0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0FFH
            DB      0FFH,0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0C1H
            DB      0C2H,0C4H,0C5H,0C5H,0C4H,0C2H,0C1H,0C0H
            DB      0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0C0H
            DB      0C1H,0C2H,0C4H,0C5H,0C5H,0C4H,0C2H,0C1H
            DB      0C0H,0C0H,0C0H,0C0H,0C0H,0C0H,0FFH,0FFH

            END

                

สามารถ download ไฟล์ตัวอย่างของบอร์ด พร้อม assembler ได้เลยครับ


เขียนโดย : ETT
Author : ETT team
e-mail : sales@etteam.com
วันที่ทำการปรับปรุง : ๒๘ ธ.ค. ๒๕๔๓