英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流
标题:
12232汉字字符液晶串口驱动程序转
[打印本页]
作者:
star
时间:
2012-8-21 16:20
标题:
12232汉字字符液晶串口驱动程序转
本帖最后由 star 于 2012-8-21 16:23 编辑
12232汉字字符液晶串口驱动程序,
另外上传了,汉字内码的查询工具。
;12232汉字字符液晶串口驱动程序
;
; 晶振:4MHZ OR 12Mhz
; 通信端口定义
; sclk RBO
; sid RB1
; cs RB2
#include<p16f877a.inc>
__CONFIG 0x3fb1 ;4Mhz
;__CONFIG 0x3fb2 ;12Mhz
#DEFINE SCLK1 BSF PORTB,0 ;
#DEFINE SCLK0 BCF PORTB,0 ;
#DEFINE SID1 BSF PORTB,1 ;
#DEFINE SID0 BCF PORTB,1 ;
#DEFINE CS1 BSF PORTB,2 ;
#DEFINE CS0 BCF PORTB,2 ;
ORT I/O DEFINE
CBLOCK 0x70 ;won't have to change banks
X
Y
H
M
L
I
CDATA
MDATA
COUNT
COUNT1
ENDC
ORG 0
NOP
GOTO MAIN
ORG 4
MAIN
BANKSEL TRISB
;CLRW ;00000000
CLRF TRISB ;SET PORTB OUT
CLRF PIE1
CLRF PIE2
BANKSEL PIR1
CLRF PIR1
CLRF PIR2
BCF INTCON,PEIE
BCF INTCON,GIE
CLRF PORTB
;ABOVE INITIAL THE SYSTEM
CALL DELAY1
; CALL DELAY1
MOVLW 30H
MOVWF CDATA
CALL SEND_COMMAND
MOVLW 02H
MOVWF CDATA
CALL SEND_COMMAND
MOVLW 06H
MOVWF CDATA
CALL SEND_COMMAND
MOVLW 0CH
MOVWF CDATA
CALL SEND_COMMAND
MOVLW 01H
MOVWF CDATA
CALL SEND_COMMAND
MOVLW 80H
MOVWF CDATA
CALL SEND_COMMAND
CALL DELAY1
CLRF H
MOVLW .12
MOVWF COUNT1
RER
MOVFW H
CALL TABLE1
MOVWF CDATA
CALL SEND_DATA
INCF H,F
DECFSZ COUNT1,F
GOTO RER
MOVLW 0X90
MOVWF CDATA
CALL SEND_COMMAND
CLRF H
MOVLW .12
MOVWF COUNT1
RER1
MOVFW H
CALL TABLE2
MOVWF CDATA
CALL SEND_DATA
INCF H,F
DECFSZ COUNT1,F
GOTO RER1
GOTO $
;ABOVE INTITAL THE LCD
;-------------------------------------------SEND-COMMAND_FUNCTION-----------
SEND_COMMAND
;BANKSEL PORTB
CS1
SCLK0
MOVLW 0F8H
MOVWF MDATA
MOVLW .8
MOVWF I
_CM1
NOP
RLF MDATA,F
BTFSS STATUS,C
GOTO SEND0
SID1
GOTO SEND_END
SEND0
SID0
GOTO SEND_END
SEND_END
SCLK0
NOP
SCLK1
DECFSZ I,F
GOTO _CM1
MOVF CDATA,W
MOVWF MDATA
MOVLW .8
MOVWF I
MOVLW 0F0H
ANDWF MDATA,F
_CM2
RLF MDATA,F
BTFSS STATUS,C
GOTO SEND0_1
SID1
GOTO SEND_END_1
SEND0_1
SID0
GOTO SEND_END_1
SEND_END_1
SCLK0
NOP
SCLK1
DECFSZ I,F
GOTO _CM2
MOVF CDATA,W
MOVWF MDATA
MOVLW .8
MOVWF I
RLF MDATA,F
RLF MDATA,F
RLF MDATA,F
RLF MDATA,F
MOVLW 0F0H
ANDWF MDATA,F
_CM3
RLF MDATA,F
BTFSS STATUS,C
GOTO SEND0_2
SID1
GOTO SEND_END_2
SEND0_2
SID0
GOTO SEND_END_2
SEND_END_2
SCLK0
NOP
SCLK1
DECFSZ I,F
GOTO _CM3
CS0
MOVLW .2
MOVWF COUNT
DECFSZ COUNT,F
GOTO $-1
RETURN
;--------------------------------
SEND_DATA_FUNCTION__________________________________
SEND_DATA
;BANKSEL PORTB
CS1
SCLK0
MOVLW 0FAH
MOVWF MDATA
MOVLW .8
MOVWF I
_DM1
RLF MDATA,F
BTFSS STATUS,C
GOTO DSEND0
SID1
GOTO DSEND_END
DSEND0
SID0
GOTO DSEND_END
DSEND_END
SCLK0
NOP
SCLK1
DECFSZ I,F
GOTO _DM1
MOVF CDATA,W
MOVWF MDATA
MOVLW .8
MOVWF I
MOVLW 0F0H
ANDWF MDATA,F
_DM2
RLF MDATA,F
BTFSS STATUS,C
GOTO DSEND0_1
SID1
GOTO DSEND_END_1
DSEND0_1
SID0
GOTO DSEND_END_1
DSEND_END_1
SCLK0
NOP
SCLK1
DECFSZ I,F
GOTO _DM2
MOVF CDATA,W
MOVWF MDATA
MOVLW .8
MOVWF I
RLF MDATA,F
RLF MDATA,F
RLF MDATA,F
RLF MDATA,F
MOVLW 0F0H
ANDWF MDATA,F
_DM3
RLF MDATA,F
BTFSS STATUS,C
GOTO DSEND0_2
SID1
GOTO DSEND_END_2
DSEND0_2
SID0
GOTO DSEND_END_2
DSEND_END_2
SCLK0
NOP
SCLK1
DECFSZ I,F
GOTO _DM3
CS0
MOVLW .2
MOVWF COUNT
DECFSZ COUNT,F
GOTO $-1
RETURN
DELAY1
MOVLW .5 ;150MS_DELAY
MOVWF X
L1
MOVLW .30
MOVLW Y
DECFSZ Y,F
GOTO $-1
DECFSZ X,F
GOTO L1
RETURN
TABLE1
ADDWF PCL,F
DT "QQ:102126913"
TABLE2
ADDWF PCL,F
DT 0xd2,0xba,0xbe,0xa7,0xb2,0xe2,0xca,0xd4,0xb3,0xcc,0xd0,0xf2
END
;
;
;
;
欢迎光临 英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 (http://enroobbs.com/)
Powered by Discuz! X3.2