betway88必威体育
电子产品世界 » 论坛首页 » 综合技术 » pic16c74与lcd接口

共1条 1/1 1 跳转至

pic16c74与lcd接口

菜鸟
2005-09-16 15:24:46     打赏
;*****SRF*** PC EQU 02H STATUS EQU 3H RA EQU 5 RB EQU 6 RC EQU 7 RD EQU 8 RE EQU 9 TEMP EQU 20H KEYIN EQU 21H BUFFER EQU 22H BUFFER1 EQU 23H BUFFER2 EQU 24H LCD_ST EQU 30H LCDCOM EQU 31H X_COUNT EQU 32H Y_COUNT EQU 33H LDATA1 EQU 50H LDATA2 EQU 52H LDATA3 EQU 53H LDATA4 EQU 54H LDATA5 EQU 55H LDATA6 EQU 56H LDATA7 EQU 57H LDATA8 EQU 58H LDATA9 EQU 59H;LDATA1-16LCD显示的数据 LDATA10 EQU 5AH LDATA11 EQU 5BH LDATA12 EQU 5CH LDATA13 EQU 5DH LDATA14 EQU 5EH LDATA15 EQU 5FH LDATA16 EQU 60H TABADD EQU 25H TRISA EQU 85H TRISB EQU 86H TRISC EQU 87H TRISD EQU 88H TRISE EQU 89H ;****BIT*********** ;&&&&&&&&&&&&&&&&&&&&& ;&&&&&&&&&&&&&&&&&&& ;RD(RST CS2 CS1 E XX XX XX XX ) ;RC(RW DI XX XX XX XX XX XX ) ;RB(D7 D6 D5 D4 D3 D2 D1 D0) RST EQU 7 CS2 EQU 6;*********** CS1 EQU 5;LCD的控制引脚 E EQU 4;*********** RW EQU 7 DI EQU 6 ;&&&&&&&&&&&&&&&&&&&& ;******RESET********* PIC74 EQU 0H ;**************** ORG PIC74 GOTO MAIN DELAY1 MOVLW 0FFH MOVWF TEMP LOOP_DELAY DECFSZ TEMP,1 GOTO LOOP_DELAY RETURN WAIT BSF STATUS,5 MOVLW B'11111111' MOVWF TRISB BCF STATUS,5 NOP NOP BCF RC,DI BSF RC,RW BSF RD,E BUSY BTFSC RB,7 GOTO BUSY BCF RD,E NOP NOP BSF STATUS,5 MOVLW B'00000000' MOVWF TRISB BCF STATUS,5 RETURN WRITECOM MOVWF RB BCF RC,DI BCF RC,RW BSF RD,E CALL DELAY1 BCF RD,E RETURN WRITEDATA MOVWF RB BCF RC,RW BSF RC,DI BSF RD,E CALL DELAY1 BCF RD,E RETURN LCDDIS MOVF LDATA1,0; 1 CALL WRITEDATA CALL WAIT MOVF LDATA2,0; 2 CALL WRITEDATA CALL WAIT MOVF LDATA3,0; 3 CALL WRITEDATA CALL WAIT MOVF LDATA4,0; 4 CALL WRITEDATA CALL WAIT MOVF LDATA5,0; 5 CALL WRITEDATA CALL WAIT MOVF LDATA6,0; 6 CALL WRITEDATA CALL WAIT MOVF LDATA7,0; 7 CALL WRITEDATA CALL WAIT MOVF LDATA8,0; 8 CALL WRITEDATA CALL WAIT MOVF LDATA9,0; 9 CALL WRITEDATA CALL WAIT MOVF LDATA10,0; 10 CALL WRITEDATA CALL WAIT MOVF LDATA11,0; 11 CALL WRITEDATA CALL WAIT MOVF LDATA12,0; 12 CALL WRITEDATA CALL WAIT MOVF LDATA13,0; 13 CALL WRITEDATA CALL WAIT MOVF LDATA14,0; 14 CALL WRITEDATA CALL WAIT MOVF LDATA15,0; 15 CALL WRITEDATA CALL WAIT MOVF LDATA16,0; 16 CALL WRITEDATA CALL WAIT RETURN MAIN BSF STATUS,5 MOVLW B'00000000' MOVWF TRISB MOVLW B'00000000' MOVWF TRISC MOVLW B'00000000' MOVWF TRISD BCF STATUS,5 ;RD(RST CS2 CS1 E XX XX XX XX ) ;RC(RW DI XX XX XX XX XX XX ) ;RB(D7 D6 D5 D4 D3 D2 D1 D0) CLRF RB CLRF RC CLRF RD NOP BCF RD,RST;复位信号RST有效 NOP NOP BSF RD,RST ;******************** ;初始化 ;******************** BCF RD,CS1; BSF RD,CS2;CS1低CS2高左64列有效 BSF RD,E;使能为高有效 MOVLW B'00111111';(03FH)打开显示 CALL WRITECOM CALL WAIT NOP MOVLW 040H; 设Y的坐标 CALL WRITECOM CALL WAIT NOP MOVLW 0B8H; 设X的坐标 CALL WRITECOM CALL WAIT NOP MOVLW 0C0H; 设开始行 CALL WRITECOM CALL WAIT BSF RD,CS1; BCF RD,CS2;CS2低CS1高右64列有效 MOVLW B'00111111';(03FH)打开显示 CALL WRITECOM CALL WAIT NOP MOVLW 040H; CALL WRITECOM CALL WAIT NOP MOVLW 0B8H CALL WRITECOM CALL WAIT NOP MOVLW 0C0H CALL WRITECOM CALL WAIT ; ;**********TEST1****************** NOP MOVLW 00H MOVWF X_COUNT DIS_X1 MOVF X_COUNT,0 ADDLW 0B8H BCF RD,CS1 BSF RD,CS2 CALL WRITECOM CALL WAIT NOP NOP MOVLW 00H MOVWF Y_COUNT DIS_Y1 MOVLW 0AAH BCF RD,CS1 BSF RD,CS2 CALL WRITEDATA CALL WAIT INCF Y_COUNT,1 MOVLW 40H;64 SUBWF Y_COUNT,0 SKPZ GOTO DIS_Y1 INCF X_COUNT,1 MOVLW 08H SUBWF X_COUNT,0 SKPZ GOTO DIS_X1 NOP NOP NOP ;**********TEST2********** MOVLW 00H MOVWF X_COUNT DIS_X MOVF X_COUNT,0 ADDLW 0B8H BSF RD,CS1 BCF RD,CS2 CALL WRITECOM CALL WAIT MOVLW 00H MOVWF Y_COUNT DIS_Y MOVLW 055H BSF RD,CS1 BCF RD,CS2 CALL WRITEDATA CALL WAIT INCF Y_COUNT,1 MOVLW 40H;64 SUBWF Y_COUNT,0 SKPZ GOTO DIS_Y INCF X_COUNT,1 MOVLW 08H SUBWF X_COUNT,0 SKPZ GOTO DIS_X NOP NOP NOP; ;GOTO YES ; BCF RD,RST NOP ; BSF RD,RST NOP ;0x04,0x04,0xE4,0x24,0x24,0x64,0xB4,0x2F, ;0x24,0xA4,0x64,0x24,0x24,0xE6,0x04,0x00, ;0x00,0x00,0x7F,0x04,0x05,0x05,0x05,0x7F, ;0x05,0x05,0x05,0x25,0x44,0x3F,0x00,0x00 NOP ;写“南”字 第三列 BCF RD,CS1 BSF RD,CS2 MOVLW 040H; 设Y的坐标 CALL WRITECOM CALL WAIT NOP MOVLW 0BCH;设X的坐标 CALL WRITECOM CALL WAIT NOP MOVLW 0C0H;设开始行 CALL WRITECOM CALL WAIT NOP ;0x04,0x04,0xE4,0x24,0x24,0x64,0xB4,0x2F, ;0x24,0xA4,0x64,0x24,0x24,0xE6,0x04,0x00, ;0x00,0x00,0x7F,0x04,0x05,0x05,0x05,0x7F, ;0x05,0x05,0x05,0x25,0x44,0x3F,0x00,0x00 ;“南”字的上半部 MOVLW 04H MOVWF LDATA1 MOVLW 04H MOVWF LDATA2 MOVLW 0E4H MOVWF LDATA3 MOVLW 024H MOVWF LDATA4 MOVLW 024H MOVWF LDATA5 MOVLW 064H MOVWF LDATA6 MOVLW 0B4H; MOVWF LDATA7 MOVLW 02FH; MOVWF LDATA8 MOVLW 024H; MOVWF LDATA9 MOVLW 0A4H; MOVWF LDATA10 MOVLW 064H; MOVWF LDATA11 MOVLW 024H; MOVWF LDATA12 MOVLW 024H; MOVWF LDATA13 MOVLW 0E6H; MOVWF LDATA14 MOVLW 04H; MOVWF LDATA15 MOVLW 00H; MOVWF LDATA16 CALL LCDDIS NOP ;“南”字的下半部 BCF RD,CS1 BSF RD,CS2 MOVLW 040H;设Y的坐标 CALL WRITECOM CALL WAIT NOP MOVLW 0BDH;设X的坐标 CALL WRITECOM CALL WAIT NOP ;MOVLW 0C8H;设开始行 ;CALL WRITECOM ;CALL WAIT NOP ;0x04,0x04,0xE4,0x24,0x24,0x64,0xB4,0x2F, ;0x24,0xA4,0x64,0x24,0x24,0xE6,0x04,0x00, ;0x00,0x00,0x7F,0x04,0x05,0x05,0x05,0x7F, ;0x05,0x05,0x05,0x25,0x44,0x3F,0x00,0x00 MOVLW 00H; MOVWF LDATA1 MOVLW 00H; MOVWF LDATA2 MOVLW 07FH; MOVWF LDATA3 MOVLW 04H; MOVWF LDATA4 MOVLW 05H; MOVWF LDATA5 MOVLW 05H; MOVWF LDATA6 MOVLW 05H; MOVWF LDATA7 MOVLW 07FH; MOVWF LDATA8 MOVLW 05H; MOVWF LDATA9 MOVLW 05H; MOVWF LDATA10 MOVLW 05H; MOVWF LDATA11 MOVLW 025H; MOVWF LDATA12 MOVLW 044H; MOVWF LDATA13 MOVLW 03FH; MOVWF LDATA14 MOVLW 00H; MOVWF LDATA15 MOVLW 00H; MOVWF LDATA16 CALL LCDDIS NOP ;写“南”字 第四列 BCF RD,CS1 BSF RD,CS2 MOVLW 040H; 设Y的坐标 CALL WRITECOM CALL WAIT NOP MOVLW 0BEH;设X的坐标 CALL WRITECOM CALL WAIT NOP MOVLW 0C0H;设开始行 CALL WRITECOM CALL WAIT NOP ;0x04,0x04,0xE4,0x24,0x24,0x64,0xB4,0x2F, ;0x24,0xA4,0x64,0x24,0x24,0xE6,0x04,0x00, ;0x00,0x00,0x7F,0x04,0x05,0x05,0x05,0x7F, ;0x05,0x05,0x05,0x25,0x44,0x3F,0x00,0x00 ;“南”字的上半部 MOVLW 04H MOVWF LDATA1 MOVLW 04H MOVWF LDATA2 MOVLW 0E4H MOVWF LDATA3 MOVLW 024H MOVWF LDATA4 MOVLW 024H MOVWF LDATA5 MOVLW 064H MOVWF LDATA6 MOVLW 0B4H; MOVWF LDATA7 MOVLW 02FH; MOVWF LDATA8 MOVLW 024H; MOVWF LDATA9 MOVLW 0A4H; MOVWF LDATA10 MOVLW 064H; MOVWF LDATA11 MOVLW 024H; MOVWF LDATA12 MOVLW 024H; MOVWF LDATA13 MOVLW 0E6H; MOVWF LDATA14 MOVLW 04H; MOVWF LDATA15 MOVLW 00H; MOVWF LDATA16 CALL LCDDIS NOP ;“南”字的下半部 BCF RD,CS1 BSF RD,CS2 MOVLW 040H;设Y的坐标 CALL WRITECOM CALL WAIT NOP MOVLW 0BFH;设X的坐标 CALL WRITECOM CALL WAIT NOP ;MOVLW 0C8H;设开始行 ;CALL WRITECOM ;CALL WAIT NOP ;0x04,0x04,0xE4,0x24,0x24,0x64,0xB4,0x2F, ;0x24,0xA4,0x64,0x24,0x24,0xE6,0x04,0x00, ;0x00,0x00,0x7F,0x04,0x05,0x05,0x05,0x7F, ;0x05,0x05,0x05,0x25,0x44,0x3F,0x00,0x00 MOVLW 00H; MOVWF LDATA1 MOVLW 00H; MOVWF LDATA2 MOVLW 07FH; MOVWF LDATA3 MOVLW 04H; MOVWF LDATA4 MOVLW 05H; MOVWF LDATA5 MOVLW 05H; MOVWF LDATA6 MOVLW 05H; MOVWF LDATA7 MOVLW 07FH; MOVWF LDATA8 MOVLW 05H; MOVWF LDATA9 MOVLW 05H; MOVWF LDATA10 MOVLW 05H; MOVWF LDATA11 MOVLW 025H; MOVWF LDATA12 MOVLW 044H; MOVWF LDATA13 MOVLW 03FH; MOVWF LDATA14 MOVLW 00H; MOVWF LDATA15 MOVLW 00H; MOVWF LDATA16 CALL LCDDIS NOP ;换半屏显示“南” ;上半部 BSF RD,CS1 BCF RD,CS2 MOVLW 040H; 设Y的坐标 CALL WRITECOM CALL WAIT NOP MOVLW 0B8H;设X的坐标 CALL WRITECOM CALL WAIT NOP MOVLW 0C0H;设开始行 CALL WRITECOM CALL WAIT NOP ;0x04,0x04,0xE4,0x24,0x24,0x64,0xB4,0x2F, ;0x24,0xA4,0x64,0x24,0x24,0xE6,0x04,0x00, ;0x00,0x00,0x7F,0x04,0x05,0x05,0x05,0x7F, ;0x05,0x05,0x05,0x25,0x44,0x3F,0x00,0x00 MOVLW 04H; 1 CALL WRITEDATA CALL WAIT MOVLW 04H; 2 CALL WRITEDATA CALL WAIT MOVLW 0E4H; 3 CALL WRITEDATA CALL WAIT MOVLW 024H; 4 CALL WRITEDATA CALL WAIT MOVLW 024H; 5 CALL WRITEDATA CALL WAIT MOVLW 064H; 6 CALL WRITEDATA CALL WAIT MOVLW 0B4H; 7 CALL WRITEDATA CALL WAIT MOVLW 02FH; 8 CALL WRITEDATA CALL WAIT MOVLW 024H; 9 CALL WRITEDATA CALL WAIT MOVLW 0A4H; 10 CALL WRITEDATA CALL WAIT MOVLW 064H; 11 CALL WRITEDATA CALL WAIT MOVLW 024H; 12 CALL WRITEDATA CALL WAIT MOVLW 024H; 13 CALL WRITEDATA CALL WAIT MOVLW 0E6H; 14 CALL WRITEDATA CALL WAIT MOVLW 04H; 15 CALL WRITEDATA CALL WAIT MOVLW 00H; 16 CALL WRITEDATA CALL WAIT ;下半部 BSF RD,CS1 BCF RD,CS2 MOVLW 040H;设Y的坐标 CALL WRITECOM CALL WAIT NOP MOVLW 0B9H;设X的坐标 CALL WRITECOM CALL WAIT NOP ;MOVLW 0C8H;设开始行 ;CALL WRITECOM ;SCALL WAIT NOP MOVLW 00H; 1 CALL WRITEDATA CALL WAIT MOVLW 00H; 2 CALL WRITEDATA CALL WAIT MOVLW 07FH; 3 CALL WRITEDATA CALL WAIT MOVLW 04H; 4 CALL WRITEDATA CALL WAIT MOVLW 05H; 5 CALL WRITEDATA CALL WAIT MOVLW 05H; 6 CALL WRITEDATA CALL WAIT MOVLW 05H; 7 CALL WRITEDATA CALL WAIT MOVLW 07FH; 8 CALL WRITEDATA CALL WAIT MOVLW 05H; 9 CALL WRITEDATA CALL WAIT MOVLW 05H; 10 CALL WRITEDATA CALL WAIT MOVLW 05H; 11 CALL WRITEDATA CALL WAIT MOVLW 025H; 12 CALL WRITEDATA CALL WAIT MOVLW 044H; 13 CALL WRITEDATA CALL WAIT MOVLW 03FH; 14 CALL WRITEDATA CALL WAIT MOVLW 00H; 15 CALL WRITEDATA CALL WAIT MOVLW 00H; 16 CALL WRITEDATA CALL WAIT NOP NOP NOP END



关键词: pic16c74     接口     COUNT     MOVLW     M    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]