您的位置 首页 电子

CD1502驱动程序具体解说进程及源码

CD1502驱动程序详细讲解过程及源码-LCD部分用到的RAM0200H~~~~021FH用到的Rn有R15/R14。

;LCD部分用到的RAM0200H~~~~021FH用到的Rn有R15/R14

;LCD复位子程序(LCD_REST)不需要设事前置直接调用即可

;半屏显现子程序(LCD)在调用前有必要送入页地址 例如:MOV.B #0B8H,LCD_PAGE_BRAM

;CALL#LCD显现上屏

;:MOV.B #0BAH,LCD_PAGE_BRAM

;CALL#LCD显现下屏

;LCDUP_WORD0_BRAM~~~LCDUP_WORD6_RAM是上屏显现字的代码寄存器一屏显现7个字

;LCDDOWN_WORD0_BRAM~~~LCDDOWN_WORD6_RAM是下屏显现字的代码寄存器一屏显现7个字

;每屏显现是以中心为基准向两头均匀显现在调用半屏显现子程序时现已主动核算LCD的列地址

;清屏指令可分全屏铲除(LCD_CLEAR_ALL)和半屏铲除(LCD_CLEAR)

;注 全屏铲除子程序不需进口直接调用就行而半屏铲除子程序在调用前进口与半屏显现子程序相同

#i nclude“MSP430x14x.h”

NAME LCD

MODULE LCD

PUBLICLCD

RSEG PROM

;=========LCD==================================

;A0=1为数据A0=0为指令

#defineA004H

#defineE102H

#defineE201H

#defineBIT_OUTP4OUT

#defineDATA_BUSP2OUT

;=============LCD____8RAM的位界说===============

#defineLCD_COM_BRAM0200H

#defineLCD_DATA_BRAM0201H

#defineLCD_LIE_BRAM0202H

#defineLCD_PAGE_BRAM0203H

;=============LCD_UP_RAM============================

#defineLCDUP_WORD0_BRAM 0204H

#defineLCDUP_WORD1_BRAM 0205H

#defineLCDUP_WORD2_BRAM 0206H

#defineLCDUP_WORD3_BRAM 0207H

#defineLCDUP_WORD4_BRAM 0208H

#defineLCDUP_WORD5_BRAM 0209H

#defineLCDUP_WORD6_BRAM 020AH

;==========下面的RAM只是在测验状况下才会用到=====

#defineLCDUP_WORD7_BRAM 020BH

;=============LCD_DOWN_RAM=====================

#defineLCDDOWN_WORD0_BRAM 020CH

#defineLCDDOWN_WORD1_BRAM 020DH

#defineLCDDOWN_WORD2_BRAM 020EH

#defineLCDDOWN_WORD3_BRAM 020FH

#defineLCDDOWN_WORD4_BRAM 0210H

#defineLCDDOWN_WORD5_BRAM 0211H

#defineLCDDOWN_WORD6_BRAM 0212H

;==========下面的RAM只是在测验状况下才会用到=====

#defineLCDDOWN_WORD7_BRAM 0213H

;=============LCD_数据寄存器_RAM=================

#defineLCD_R0_BRAM0214H

#defineLCD_R1_BRAM0215H

;=============LCD____16RAM的位界说===============

#defineLCD_COUNT_WRAM021CH

#defineLCD_WORD_WRAM021EH

;=============LCD____BIT的位界说===============

#defineLCD_BIT_RAM0220H

#defineLCD_E1_E20000H

;是LCD左右屏挑选为BIT=1选通左面BIT=0选通右边

#defineLCD_INV02H

;高电平时显现反白

;—————————————————

;===========================================================

LCD_E1_COM

BIC.B#A0,&BIT_OUT;A0置低 设为指令通道

MOV.BLCD_COM_BRAM,&LCD_BUS ;输出指令

BIS.B#E1,&BIT_OUT ;开E1

BIC.B#E1,&BIT_OUT ;关E1

RET;反回

LCD_E2_COM

BIC.B#A0,&BIT_OUT ;A0置低 设为指令通道

MOV.BLCD_COM_BRAM,&LCD_BUS ;输出指令

BIS.B#E2,&BIT_OUT ;开E2

BIC.B#E2,&BIT_OUT ;关E2

RET;反回

LCD_E1_DATA

BIS.B#A0,&BIT_OUT ;A0置高 设为指令通道

MOV.BLCD_DATA_BRAM,&LCD_BUS ;输出指令

BIS.B#E1,&BIT_OUT ;开E1

BIC.B#E1,&BIT_OUT ;关E1

RET;反回

LCD_E2_DATA

BIS.B#A0,&BIT_OUT ;A0置高 设为数据通道

MOV.BLCD_DATA_BRAM,&LCD_BUS ;输出指令

BIS.B#E2,&BIT_OUT ;开E2

BIC.B#E2,&BIT_OUT ;关E2

RET;反回

;================CLEAR_LCD_DISPALY==============

;每次直接调用程序就能够清全屏显现 不须进口

LCD_CLEAR_ALL

CLRR15

CLRR14

LCD_CLEAR_ALL_1

BIS.B#0B8H,R15

MOV.BR15,LCD_COM_BRAM

CALL#LCD_E1_COM

CALL#LCD_E2_COM

MOV.B#00H,LCD_COM_BRAM

CALL#LCD_E1_COM

CALL#LCD_E2_COM

MOV.B#61D,R14

LCD_CLEAR_ALL_2

MOV.B#000H,LCD_DATA_BRAM

CALL#LCD_E1_DATA

CALL#LCD_E2_DATA

CLRZ

DEC.BR14

JNZLCD_CLEAR_ALL_2

INC.BR15

CLRZ

CMP.B#0BCH,R15

JNELCD_CLEAR_ALL_1

RET

;================CLEAR_LCD_DISPALY=============

;每次直接调用程序就能够清半屏显现

;调用前有必要送入页地址到LCD_PAGE_RAM(页地址寄存器)

;例如:MOV.B #0B8H,LCD_PAGE_BRAM

;:CALL #LCD_CLEAR 便是清上半屏显现

;:MOV.B #0BAH,LCD_PAGE_BRAM

;:CALL #LCD_CLEAR 便是清下半屏显现

LCD_CLEAR

CLRR15

MOV.BLCD_PAGE_BRAM,LCD_LIE_BRAM

ADD.B#2D,LCD_LIE_BRAM

LCD_CLEAR_1

BIS.BLCD_PAGE_BRAM,R15

MOV.BR15,LCD_COM_BRAM

CALL#LCD_E1_COM

CALL#LCD_E2_COM

MOV.B#00H,LCD_COM_BRAM

CALL#LCD_E1_COM

CALL#LCD_E2_COM

MOV#61D,R14

LCD_CLEAR_2

MOV.B#00H,LCD_DATA_BRAM

CALL#LCD_E1_DATA

CALL#LCD_E2_DATA

CLRZ

DEC.BR14

JNZLCD_CLEAR_2

INC.BR15

CLRZ

CMP.BLCD_LIE_BRAM,R15

JNZLCD_CLEAR_1

RET

;===============RESETTING_LCD_MODE=============

;调用此程序是使LCD复位并进入作业状况

LCD_REST

MOV.B#0E2H,LCD_COM_BRAM ;复位

CALL#LCD_E1_COM

CALL#LCD_E2_COM

MOV.B#0A4H,LCD_COM_BRAM ;封闭休闲状况

CALL#LCD_E1_COM

CALL#LCD_E2_COM

MOV.B#0A9H,LCD_COM_BRAM ;设置1/32占空比

CALL#LCD_E1_COM

CALL#LCD_E2_COM

MOV.B#0A0H,LCD_COM_BRAM ;正向排序设置

CALL#LCD_E1_COM

CALL#LCD_E2_COM

MOV.B#0C0H,LCD_COM_BRAM ;设置显现开始行为榜首行

CALL#LCD_E1_COM

CALL#LCD_E2_COM

MOV.B#0AFH,LCD_COM_BRAM ;开显现设置

CALL#LCD_E1_COM

CALL#LCD_E2_COM

RET

;查LCD PAGE #0B8H.#0B9H/#0BAH.#0BBH上屏需要显现的个数

;这段程序已测验过03-3-12 9:55

;R15/R14/R13

LCD_CHK

CLRLCD_COUNT_RAM

MOV.B#8,LCD_R0_RAM;查殉上屏需要显现的个数,一屏最多能够显现7个16X16

CLR.BLCD_LIE_BRAM;清上屏查殉成果寄存器

MOVLCD_WORD_RAM,R14 ;把需要查看字的首位16位地址放进R14.LCD_WORD_RAM

;界说时有必要是16位地址

LCD_CHK_0

DEC.BLCD_R0_RAM

JZLCD_CHK_1;测验完结退出

CLRZ

MOV.B@R14+,LCD_COUNT_RAM

TST.BLCD_COUNT_RAM;测验每个字寄存器是否为零

JZLCD_CHK_0;为零时转

INC.BLCD_LIE_BRAM;大于零查殉成果寄存器加一

JMPLCD_CHK_0;反回测验

LCD_CHK_1

CLRLCD_COUNT_RAM

MOV.BLCD_LIE_BRAM,LCD_COUNT_RAM

MOVLCD_COUNT_RAM,&MPY ;把检测的成果乘以16

MOV#16D,&OP2

MOV&RESLO,LCD_COUNT_RAM ;相乘的成果放回寄存器

MOV.BLCD_COUNT_RAM,LCD_LIE_BRAM

RRA.BLCD_LIE_BRAM;成果除2.放到上屏页的寄存器

MOV.B#61D,LCD_COUNT_RAM

SUB.BLCD_LIE_BRAM,LCD_COUNT_RAM

MOV.BLCD_COUNT_RAM,LCD_LIE_BRAM

RET

;调用前有必要把要显现屏榜首个字的地址放在R15内

;列:MOV#LCDUP_WORD0_BRAM,LCD_WORD_RAM

;MOV#LCDDOWN_WORD0_BRAM,LCD_WORD_RAM

;用到的寄存器R15/R14

LCD

CLRZ

CMP.B#0B8H,LCD_PAGE_BRAM

JNELCD_1

MOV#LCDUP_WORD0_BRAM,LCD_WORD_RAM

JMPLCD_0

LCD_1 MOV#LCDDOWN_WORD0_BRAM,LCD_WORD_RAM

LCD_0 CALL#LCD_CHK

BIS.B#BIT0,LCD_BIT_RAM

MOV.B#7D,LCD_R1_RAM

;每次调用均接连显现7个16X16的字而遇到字寄存器是

MOVLCD_WORD_RAM,R15 ;零就反回由于字表里边是没有零的

LCD_DISPALY

CLRR14

MOV.B@R15+,R14

TSTR14;R15是显现字首位地址寄存器,预备用于直接寻址

JZLCD_RET;字寄存器是零就反回

MOV#32D,&MPY;查表然后吧成果送到寄存器

MOVR14,&OP2

MOV&RESLO,LCD_COUNT_RAM

ADD#LCD_DB,LCD_COUNT_RAM

MOVLCD_COUNT_RAM,R14

MOV.B#32D,LCD_R0_RAM;R14用于放核算查找数据的个数

LCD_PAGE

MOV.BLCD_PAGE_BRAM,LCD_COM_BRAM;把页地址送到指令寄存器

CLRZ

BIT.B#BIT0,LCD_BIT_RAM

;LCD_BIT_RAM的BIT0=LCD_E1_E2为高时转到E1发送,第便是E2

JZLCD_PAGE_E2;Z为零就转到E2不然向下作业

LCD_PAGE_E1

CALL#LCD_E1_COM;向E1发送页地址

JMPLCD_LIE;跳去列发送

LCD_PAGE_E2

CALL#LCD_E2_COM;向E2发送页地址

LCD_LIE

MOV.BLCD_LIE_BRAM,LCD_COM_BRAM;把列地址送到指令寄存器

CLRZ

BIT.B#BIT0,LCD_BIT_RAM

;LCD_BIT_RAM为高时转到E1发送,第便是E2

JZLCD_LIE_E2;Z为零就转到E2不然向下作业

LCD_LIE_E1

CALL#LCD_E1_COM;向E1发送列地址

JMPLCD_DATA

LCD_LIE_E2

CALL#LCD_E2_COM;向E2发送列地址

LCD_DATA

CALL#LCD_FIND_DATA;调用数据发送指令

CLRZ

BIT.B#BIT0,LCD_PAGE_BRAM ;测验页寄存器的BIT0位

JNZLCD_PAGE_0;大于零(便是BIT0=1)就转

BIS.B#BIT0,LCD_PAGE_BRAM ;把页寄存器的BIT0方位高(原来是低#0B8H/#0BAH)

JMPLCD_RETURN

LCD_PAGE_0

BIC.B#BIT0,LCD_PAGE_BRAM ;把页寄存器的BIT0方位低(原来是高#0B9H/#0BBH)

INC.BLCD_LIE_BRAM;列地址加一

CLRZ

CMP.B#61D,LCD_LIE_BRAM;查看列有没有超越61列

JNZLCD_RETURN;Z大于零就转等于零就向下作业

CLR.BLCD_LIE_BRAM;清列寄存器

CLRZ

BIT.B#BIT0,LCD_BIT_RAM ;测验LCD_BIT_RAM位在E1就转为E2 在E2就当即反回

JNZLCD_PAGE_1;Z为零就转到E2不然向下作业

JMPLCD_RET;转到子程序反回指令

LCD_PAGE_1

BIC.B#BIT0,LCD_BIT_RAM ;把LCD_BIT_RAM方位低设为E2显现状况

JMPLCD_PAGE;反回页传送指令地址

LCD_RETURN

CLRZ

DEC.BLCD_R0_RAM;查找数据的个数寄存器减1

JNZLCD_PAGE;R14大于零转回页传送指令地址

CLRZ

DEC.BLCD_R1_RAM;字个数寄存器减1

BIC.B#BIT0,LCD_PAGE_BRAM

JNZLCD_DISPALY;反回主显现调用程序

LCD_RET

RET;反回主程序

;===================================================

LCD_FIND_DATA

MOV.B@R14+,LCD_DATA_BRAM

CLRZ

BIT.B#INV_BIT,LCD_BIT_RAM

JZNO_INV

INV.BLCD_DATA_BRAM

NO_INV CLRZ

BIT.B#BIT0,LCD_BIT_RAM ;测验LCD_BIT_RAM位在E1就转为E2 在E2就当即反回

JZLCD_FIND_E2;Z为零就转到E2不然向下作业

CALL#LCD_E1_DATA;调用E1数据发送子程序

JMPLCD_FIND_DATA_RET

LCD_FIND_E2

CALL#LCD_E2_DATA;调用E2数据发送子程序

LCD_FIND_DATA_RET

RET

END LCD

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qiche/dianzi/347787.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部