当前位置:首页 > 单片机 > 单片机
[导读] #include;__CONFIG_DEBUG_OFF&_CP_ALL&_WRT_HALF&_CPD_ON&_LVP_OFF&_BODEN_OFF&_PWRTE_ON&_WDT_OFF&_HS_OSC;芯片配置字,看门狗关,上电延时开,掉电检测关,低压编程关,加密,4M晶体HS振荡#defineRSP

#include
;__CONFIG_DEBUG_OFF&_CP_ALL&_WRT_HALF&_CPD_ON&_LVP_OFF&_BODEN_OFF&_PWRTE_ON&_WDT_OFF&_HS_OSC
;芯片配置字,看门狗关,上电延时开,掉电检测关,低压编程关,加密,4M晶体HS振荡

#defineRSPORTA,5;命令/数据选择
#DEFINERWPORTA,4;读/写选择
#DEFINEEPORTA,3;使能信号
#DEFINEPSBPORTA,2;并口/串口选择(H/L)
#DEFINERSTPORTA,0;复位信号

;-----------------------------------------------
LCD_XEQU30H;页地址
LCD_YEQU31H;Y地址
COUNTEQU32H;循环计数用
COUNT1EQU33H;循环计数用
COUNT2EQU34H;循环计数用
COUNT3EQU35H

POINTEQU36H;查表偏移地址
POINT1EQU37H;查表偏移地址
POINT2EQU38H;查表偏移地址
POINT3EQU40H
TEMPEQU39H;临时寄存器
TEMP1EQU3AH;临时寄存器
;-----------------------------------------------
ORG0000H;复位地址
NOP;ICD需要的空指令
GOTOMAIN;跳转到主程序


;**********************主程序************************
MAIN
BANKSELTRISA
CLRFTRISA;A口输出
CLRFTRISD;D口输出
BANKSELADCON1
MOVLW06H
MOVWFADCON1;A口全为数字口
CLRFSTATUS

BCFRST;复位LCD
CALLDELAY;延时一段时间
BSFRST;清除复位信号
NOP
BSFPSB;并口通讯

;**************************初始化**********************
MOVLW30H;基本指令操作
CALLSEND_I
MOVLW01H;清除显示
CALLSEND_I
MOVLW06H;指定在写入或读取时,光标的移动方向
CALLSEND_I
MOVLW0CH;开显示,关光标,不闪烁
CALLSEND_I
;***********************显示汉字************************
HAN_WR2
CALLCLEAR_P;清屏
HAN_WR2A;“深圳乾龙盛电子”

CALLQUSHU
GOTO$
;************************写准备****************************
WR_ZB
MOVLW34H
CALLSEND_I
MOVFWLCD_Y;Y地址
CALLSEND_I
MOVFWLCD_X;页地址
CALLSEND_I
MOVLW30H
CALLSEND_I
RETURN

;***********************清屏*******************************
CLEAR_P
MOVLW1H;清除显示
CALLSEND_I
RETURN
;***********************取数显示程序***********************
QUSHU
CLRFPOINT;取数地址低8位
CLRFPOINT+1;取数地址高8位(因为一共需要(128/8)*64个数据)
CLRFPOINT2;POINT的临时寄存器
CLRFPOINT3;POINT+1的临时寄存器

MOVLW02H;整块屏分为上下两个小屏(每小屏共32行)
MOVWFCOUNT3
MOVLW80H;上半屏的起始地址
MOVWFLCD_X
QUSHU1
MOVLW80H;每一行的第一个字节的地址
MOVWFLCD_Y
MOVLW20H;每一小屏共32行
MOVWFCOUNT2
QUSHU2
MOVLW10H;每一行共16个字节(16*8=128)
MOVWFCOUNT1
CALLWR_ZB;调用写准备函数
QUSHU3
CALLTAB1;查表
CALLSEND_D;写入到LCD的GDROM里
CLRFPOINT3
INCFPOINT,1;偏移地址加1,查找下一个数据
BTFSCSTATUS,Z;低8位是否有溢出
INCFPOINT+1,1;有,高8位+1
DECFSZCOUNT1,1;是否写完一行16个字节
GOTOQUSHU3;否,返回去继续写
INCFLCD_Y,1;是,写下一行
DECFSZCOUNT2,1;是否写完32行
GOTOQUSHU2;否,继续写
MOVLW88H;是,写下半屏
MOVWFLCD_X
DECFSZCOUNT3,1;是否写完下半屏
GOTOQUSHU1;否,继续写
;是,开显示
MOVLW36H;扩展指令,图形显示开
CALLSEND_I
MOVLW30H;基本指令
CALLSEND_I
RETURN

;************************送数据到LCD***********************
;写数据子程序
;RS=1,RW=0,E=高脉冲,D0-D7=数据
;**********************************************************
SEND_D
MOVWFTEMP1;暂存数据
CALLCHK_BUSY;判断总线是否忙
BSFRS
BCFRW
MOVFWTEMP1
MOVWFPORTD;送出数据
BSFE
NOP
NOP
BCFE
RETURN
;************************送命令到LCD***********************
;写指令子程序
;RS=0,RW=0,E=高脉冲,D0-D7=指令码
;**********************************************************
SEND_I
MOVWFTEMP1;暂存命令
CALLCHK_BUSY;判断总线是否忙
BCFRS
BCFRW
MOVFWTEMP1
MOVWFPORTD;送命令
BSFE
NOP
NOP
BCFE
RETURN
;************************判断总线是否忙********************
;测忙碌子程序
;RS=0,RW=1,E=H,D0-D7=状态字
;**********************************************************
CHK_BUSY
BANKSELTRISD
MOVLW0FFH
MOVWFTRISD;D口设置为输入
CLRFSTATUS
MOVLW0FFH
MOVWFPORTD
BCFRS
BSFRW
CHECK_BUSY_1
NOP
NOP
NOP
BSFE
NOP
NOP
NOP
BTFSSPORTD,7;D7为高表示总线忙,为低表示总线空闲
GOTO$+6
NOP
NOP
NOP
BCFE
GOTOCHECK_BUSY_1
BCFE
BANKSELTRISD
CLRFTRISD;恢复D口为输出
CLRFSTATUS
RETURN
;***************************延时程序***************************
DELAY
MOVLW0afH
MOVWF20H
MOVLW0ffh
MOVWF21H
DECFSZ21H,1
GOTO$-1
DECFSZ20H,1
GOTO$-5
RETURN
;***************************延时程序1**************************
;显示闪烁用
DELAY1
MOVLW05H
MOVWF22H
CALLDELAY
DECFSZ22H,1
GOTO$-2
RETURN

;***************************数据表格**************************
TAB1
MOVLWLOW(TAB1A);获取数据表头的低8位地址
ADDWFPOINT,0;并上取数的低8位
MOVWFPOINT2;转存到POINT2里
BTFSCSTATUS,C;判断低8位是否有溢出
INCFPOINT3,1;是,高8位+1
MOVLWHIGH(TAB1A);获取数据表头的高8位地址
ADDWFPOINT3,0
ADDWFPOINT+1,0;并上取数的高8位

MOVWFPCLATH;准备PC的高5位
MOVFWPOINT2
MOVWFPCL;准备PC的低8位
TAB1A:;数据表
DT0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X00,0X00
DT0X18,0XFC,0XB7,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0XFF,0XFF,0XE0,0X00,0X00

DT0X1E,0X7F,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0X00,0X0F,0X7F,0XA0,0X00,0X00

DT0X1F,0X80,0X00,0X1B,0XF0,0X00,0X00,0X09,0XCF,0XFC,0X00,0X00,0X0F,0XE0,0X0F,0X00
DT0X1F,0XFE,0X00,0X19,0XF0,0X00,0X00,0X07,0XC9,0XFE,0X00,0X07,0X1F,0XE0,0X06,0X00
DT0X1F,0XFF,0XC0,0X0F,0XE0,0X00,0X00,0X03,0XC1,0XFE,0X00,0XFF,0XFF,0XE0,0X06,0X00
DT0X1F,0XC0,0X40,0X0F,0XC0,0X00,0X00,0X03,0XE7,0XFE,0X00,0X9F,0XFF,0X20,0X06,0X00
DT0X1F,0X00,0X00,0X0F,0XC0,0X00,0X00,0X07,0XE7,0XFC,0X00,0X0B,0XCF,0X20,0X06,0X00
DT0X1F,0X78,0X00,0X0F,0XC0,0X00,0X00,0X07,0XE7,0XFC,0X00,0X00,0X0F,0XE0,0X06,0X00
DT0X1F,0XFF,0X80,0X07,0XF0,0X00,0X00,0X03,0XEF,0XFC,0X00,0X00,0X3F,0XE0,0X06,0X00
DT0X13,0XFF,0XE0,0X07,0XFE,0X01,0XE0,0X01,0XCF,0XFC,0X00,0X00,0X3F,0XE0,0X06,0X60
DT0X1F,0XFC,0X00,0X07,0XE3,0X03,0XF8,0X06,0XDF,0XFC,0X00,0X1F,0XFE,0X60,0X06,0X60
DT0X1F,0X80,0X00,0X03,0X80,0X80,0XC0,0X01,0XFF,0XF8,0X00,0X0F,0X3F,0XE0,0X0F,0XE0

DT0X1C,0X00,0X00,0X01,0X80,0X41,0XC0,0X06,0XFF,0XF8,0X00,0X00,0XF3,0XE0,0X00,0X00
DT0X13,0XFC,0X00,0X03,0XFC,0X41,0XFC,0X03,0X7F,0XF0,0X00,0X00,0X0F,0XE0,0X00,0X00

DT0X1F,0XFF,0X00,0X03,0XFE,0X40,0XFF,0X00,0XFF,0XF0,0X00,0X07,0XFF,0XE0,0X07,0XC0
DT0X1F,0XC0,0X00,0X02,0XF0,0X40,0XE1,0X00,0X78,0XF0,0X00,0X3C,0XFC,0X20,0X0C,0X60
DT0X1E,0X00,0X00,0X02,0XC0,0XC0,0X60,0X00,0XF3,0X70,0X00,0X03,0XFF,0XE0,0X00,0X60
DT0X10,0X00,0X00,0X02,0X00,0X80,0X60,0X00,0X67,0X30,0X00,0X00,0X7F,0XE0,0X00,0XC0
DT0X17,0XFF,0X00,0X03,0X01,0X80,0X30,0X00,0XFC,0XB0,0X00,0X3F,0XCF,0XE0,0X01,0X80
DT0X1F,0XFA,0X00,0X03,0X03,0X80,0X18,0X01,0XFC,0X70,0X00,0X3C,0X8F,0XE0,0X03,0X00
DT0X1F,0XB0,0X00,0X03,0X0F,0X00,0X0C,0X02,0XFE,0X30,0X00,0X0D,0X3F,0X60,0X06,0X00
DT0X1F,0X00,0X00,0X03,0X0F,0X00,0X04,0X05,0XEE,0X30,0X00,0X03,0XDF,0X20,0X0C,0X00
DT0X1C,0X00,0X00,0X02,0X01,0X06,0X00,0X07,0XE3,0X30,0X01,0X00,0XDF,0XE0,0X0C,0X60
DT0X10,0X1E,0X00,0X03,0X03,0X03,0X80,0X07,0XF1,0X30,0X00,0XE0,0X33,0XE0,0X0F,0XE0

DT0X1F,0XEC,0X00,0X02,0X03,0X01,0XE0,0X09,0XF0,0X60,0X00,0X3C,0X8E,0X60,0X00,0X00
DT0X1F,0X30,0X00,0X03,0X03,0X9D,0X30,0X13,0XFC,0X60,0X00,0X1F,0X3F,0XA0,0X00,0X00

DT0X1F,0XC1,0X8C,0X02,0X81,0XF3,0X10,0X0F,0XF0,0XC0,0X03,0X87,0XC7,0XE0,0X03,0X80
DT0X1A,0X06,0X30,0X03,0X03,0X80,0X08,0X13,0XE0,0XC0,0X00,0XE3,0XF1,0XE0,0X06,0XC0
DT0X1C,0X1C,0X40,0X01,0X82,0X00,0X04,0X0F,0XE1,0X80,0X00,0X78,0XFE,0X60,0X0C,0X60
DT0X13,0XF8,0X80,0X01,0X46,0X00,0X00,0X07,0XE3,0X00,0X00,0X3E,0X7F,0XE0,0X0C,0X60
DT0X1F,0X63,0X00,0X01,0X8C,0X00,0X00,0X07,0XFE,0X00,0X00,0X0F,0X9F,0XE0,0X0D,0X60
DT0X1F,0X8E,0X04,0X01,0X47,0XEE,0X00,0X07,0XFE,0X00,0X00,0X87,0XEF,0XE0,0X0D,0X60
DT0X1E,0X3C,0X1C,0X00,0XA7,0XFF,0X8C,0X03,0XF8,0X00,0X00,0XC1,0XFF,0XE0,0X0C,0X60
DT0X1F,0X78,0X38,0X00,0XC3,0X93,0X8E,0X07,0XF0,0X00,0X00,0X78,0X7F,0XE0,0X0C,0X60
DT0X1F,0XF1,0X60,0X00,0XE3,0X80,0X06,0X07,0XF0,0X00,0X00,0X3A,0X1F,0XE0,0X06,0XC0
DT0X1F,0XE1,0X40,0X00,0X13,0XC8,0X00,0X0B,0XF0,0X00,0X00,0X1E,0X13,0XE0,0X03,0X80

DT0X17,0X8F,0X84,0X00,0X61,0XF8,0X00,0X17,0XF0,0X00,0X00,0X0F,0XB0,0XE0,0X00,0X00
DT0X1F,0X1E,0X29,0X80,0X33,0X00,0X00,0X0F,0XFC,0X00,0X00,0X43,0XFD,0X60,0X00,0X00

DT0X1E,0X7C,0X73,0X00,0X3A,0X10,0X00,0X0F,0XF4,0X00,0X00,0X21,0XFF,0XA0,0X03,0X80
DT0X15,0XF8,0XE3,0X00,0X1E,0X18,0X00,0X1F,0XF6,0X00,0X00,0X18,0XFF,0XE0,0X06,0XC0
DT0X1B,0XE1,0X86,0X00,0X1E,0X00,0X00,0X3F,0XE6,0X00,0X03,0X0E,0X7F,0XE0,0X0C,0X60
DT0X1F,0XC7,0X8C,0X00,0X1E,0X00,0X00,0X7F,0XE7,0X00,0X03,0X85,0X1B,0XE0,0X0C,0X60
DT0X1F,0X0F,0X39,0X20,0X07,0X00,0X01,0XFF,0XCF,0X00,0X01,0XC3,0XCD,0XE0,0X0D,0X60
DT0X1E,0X3E,0X73,0X40,0X03,0X80,0X0F,0XFF,0X9F,0X80,0X00,0XF1,0XF0,0X60,0X0D,0X60
DT0X18,0X7C,0XF6,0X20,0X01,0XE0,0X3F,0XFE,0X3F,0XE0,0X00,0X78,0XFE,0X60,0X0C,0X60
DT0X11,0XFB,0XE6,0X40,0X01,0XFF,0XFF,0XFC,0X7F,0XFC,0X08,0X3C,0X7F,0XE0,0X0C,0X60
DT0X1F,0XF7,0XFE,0X40,0X02,0XFF,0XFF,0XF9,0XFF,0XFF,0X00,0X0F,0X3F,0XE0,0X06,0XC0
DT0X1F,0XFF,0XFC,0X88,0X06,0XFF,0XFD,0XF3,0XFF,0XFF,0XC1,0X8F,0X9F,0XE0,0X03,0X80

DT0X1F,0XFF,0XB9,0X38,0X0E,0XFE,0X71,0XE7,0XFF,0XFF,0XE8,0XC3,0XEF,0XE0,0X00,0X00
DT0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X00,0X00
;***************************源程序结束************************
end

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除。
换一批
延伸阅读

9月2日消息,不造车的华为或将催生出更大的独角兽公司,随着阿维塔和赛力斯的入局,华为引望愈发显得引人瞩目。

关键字: 阿维塔 塞力斯 华为

加利福尼亚州圣克拉拉县2024年8月30日 /美通社/ -- 数字化转型技术解决方案公司Trianz今天宣布,该公司与Amazon Web Services (AWS)签订了...

关键字: AWS AN BSP 数字化

伦敦2024年8月29日 /美通社/ -- 英国汽车技术公司SODA.Auto推出其旗舰产品SODA V,这是全球首款涵盖汽车工程师从创意到认证的所有需求的工具,可用于创建软件定义汽车。 SODA V工具的开发耗时1.5...

关键字: 汽车 人工智能 智能驱动 BSP

北京2024年8月28日 /美通社/ -- 越来越多用户希望企业业务能7×24不间断运行,同时企业却面临越来越多业务中断的风险,如企业系统复杂性的增加,频繁的功能更新和发布等。如何确保业务连续性,提升韧性,成...

关键字: 亚马逊 解密 控制平面 BSP

8月30日消息,据媒体报道,腾讯和网易近期正在缩减他们对日本游戏市场的投资。

关键字: 腾讯 编码器 CPU

8月28日消息,今天上午,2024中国国际大数据产业博览会开幕式在贵阳举行,华为董事、质量流程IT总裁陶景文发表了演讲。

关键字: 华为 12nm EDA 半导体

8月28日消息,在2024中国国际大数据产业博览会上,华为常务董事、华为云CEO张平安发表演讲称,数字世界的话语权最终是由生态的繁荣决定的。

关键字: 华为 12nm 手机 卫星通信

要点: 有效应对环境变化,经营业绩稳中有升 落实提质增效举措,毛利润率延续升势 战略布局成效显著,战新业务引领增长 以科技创新为引领,提升企业核心竞争力 坚持高质量发展策略,塑强核心竞争优势...

关键字: 通信 BSP 电信运营商 数字经济

北京2024年8月27日 /美通社/ -- 8月21日,由中央广播电视总台与中国电影电视技术学会联合牵头组建的NVI技术创新联盟在BIRTV2024超高清全产业链发展研讨会上宣布正式成立。 活动现场 NVI技术创新联...

关键字: VI 传输协议 音频 BSP

北京2024年8月27日 /美通社/ -- 在8月23日举办的2024年长三角生态绿色一体化发展示范区联合招商会上,软通动力信息技术(集团)股份有限公司(以下简称"软通动力")与长三角投资(上海)有限...

关键字: BSP 信息技术
关闭
关闭