工作需要选择一款液晶,看到北京集粹电子设备制造有限公司的O12864-12C型液晶尺寸比较适合,于是就用手头的DSP-LF2407A板编程序看效果,调试后,效果图如下(图1):
图1
接线图如下(图2):
图2
源程序如下:
;主程序-----------LCD.ASM
.title "LCD.ASM"
.include "F2407REGS.H" ;引用头部文件
.def _c_int0
s_data .usect ".data0", 1 ;send data
temp .usect ".data0", 1 ;临时RAM
acc_H .usect ".data0", 1 ;临时保存ACC.H
acc_L .usect ".data0", 1 ;临时保存ACC.L
zkadr .usect ".data0", 1 ;汉字库地址
wht_blk .usect ".data0", 1 ;清屏效果字
;宏定义
;SDL-----IOPE1
SDL_L .macro
ldp #DP_PF2
lacl PEDATDIR
and #0fffdh
sacl PEDATDIR
.endm
SDL_H .macro
ldp #DP_PF2
lacl PEDATDIR
or #00002h
sacl PEDATDIR
.endm
;SCL------IOPE2
SCL_L .macro
ldp #DP_PF2
lacl PEDATDIR
and #0fffbh
sacl PEDATDIR
.endm
SCL_H .macro
ldp #DP_PF2
lacl PEDATDIR
ldp #DP_PF2
lacl PEDATDIR
or #00002h
sacl PEDATDIR
.endm
;SCL------IOPE2
SCL_L .macro
ldp #DP_PF2
lacl PEDATDIR
and #0fffbh
sacl PEDATDIR
.endm
SCL_H .macro
ldp #DP_PF2
lacl PEDATDIR
lacl PEDATDIR
or #00010h
sacl PEDATDIR
.endm
;CS_L------IOPE4
CS_L .macro
ldp #DP_PF2
lacl PEDATDIR
and #0ffdfh
sacl PEDATDIR
.endm
CS_H .macro
ldp #DP_PF2
lacl PEDATDIR
or #00020h
sacl PEDATDIR
.endm
;DELAY
DELY .macro n
rpt #n
nop
.endm
;==========================================================
.text
_c_int0: nop
call Init_DSP
call Init_LCD
loop:
ldp #DP_B02
splk #0ffh, wht_blk
call Clr_LCD ;黑色清屏
lar ar4, #01h
call Delay
ldp #DP_B02
splk #000h, wht_blk
call Clr_LCD ;白色清屏
lar ar4, #01h
call Delay ;延时
ldp #DP_B02
splk #XM, zkadr
call Display ;显示熊猫图片
lar ar4, #40h
call Delay ;延时
ldp #DP_B02
splk #PIG, &n,bsp;zkadr
call Display ;显示小猪图片
lar ar4, #40h ;延时
call Delay
b loop
;==========================================================
;----------------------------------------------------------
; function: Init DSP DSP初始化子程序
; input: ------
; output: ------
; usege: acc
;----------------------------------------------------------
Init_DSP:
setc intm
clrc sxm
clrc ovm
clrc cnf ;B0 被配置为数据存储空间
ldp #DP_PF1
splk #85feh, SCSR1
splk #0e8h, WDCR;不使能WDT
ldp #0
splk #0000h, IMR ;不使能
splk #0ffffh, IFR ;清全部中断标志
ldp #DP_PF2
splk #0ff00h, MCRB
lacl MCRC
and #0ff00h ;IOPE口配置为一般I/O功能
sacl MCRC
lacl PEDATDIR
or #0ff00h ;IOPE 设置为输出方式
sacl PEDATDIR
ret
;----------------------------------------------------------
; function: Clr_LCD 液晶清屏(RAM)子程序
; input: wht_blk
; output: LCD
; usege: acc,ar4,ar5,ar6,ar7
;----------------------------------------------------------
Clr_LCD:
lar ar4, #7
lar ar6, #0afh
cl_lp: mar *, ar6
adrk #1
ldp #DP_B02
sar ar6, s_data
call Wr_comd
ldp #DP_B02
splk #010h, s_data
call Wr_comd
ldp #DP_B02
splk #000h, s_data
call Wr_comd
lar ar5, #127
cl_lp0: ldp #DP_B02
lacl wht_blk
sacl s_data
call Wr_data
mar *, ar5
banz cl_lp0
mar *, ar4
banz cl_lp
ret
;----------------------------------------------------------
; function: display LCD 液晶显示子程序
; input: zkadr
; output: LCD
; usege: acc,ar4,ar5,ar6,ar7
;----------------------------------------------------------
Display:
lar ar4, #7
lar ar6, #0afh
dp_lp: mar *, ar6
adrk #1
ldp #DP_B02
sar ar6, s_data
call Wr_comd
ldp #DP_B02
splk #010h, s_data
call Wr_comd
ldp #DP_B02
splk #000h, s_data
call Wr_comd
ldp #DP_B02
lacl zkadr ;送字库首地址
lar ar5, #127 ;128列
;字库部分
;字库提取:PCtoLCD2002完美版
模式:图形
选项:阴码 逆向 列行式
PIG: ;小猪图库
.byte 0C0H,0C0H,0E0H,0E0H,0E0H,0C0H,080H,000H,------
-------------
XM: ;熊猫图库
.byte 000H,000H,000H,000H,000H,000H,000H,000H,000H,----
--------------
.end