老古开发网首页
导航:老古开发网首页文章索引文章分类显示技术→[MAX7219测试程序(汇编)]
| -文章搜索 - 最新文章 - |

MAX7219测试程序(汇编)

发布时间:2005年10月13日 点击次数:3706
来源:   作者:
 
MAX7219测试程序 
 
 
  说明:MAX7219是美国MAXIM公司推出的三线串行8位LED显示驱动器,具有多种显示(可控)方式。

;Program Test MAX7219
;This program is used to test whether MAX7219 is Ok and give a demo about ho
w to use it.
;Program Writed by Ouyijie, 1998.10
;Jialijie Computer Studio
PCL EQU 2 ;PCL = 2
DCOMMAND EQU 0x0d
DDATA EQU 0x0e
MCU_Reset
;I/O RB1 is Clock line
;I/O RB2 is LOAD line
;I/O RB3 is DATA line
;I/O RB4 is LED ,show state
movlw b''00000000'' ;set first I/O direction
tris 6
movlw b''00000000'' ;set first I/O state
movwf 0x06
Start
call MAX7219_Reset
comf 0x06,f
call Delay1s
goto Start
MAX7219_Reset ;reset MAX7219
;0x0d is display command
;0x0e is display data
movlw 0x0c
movwf DCOMMAND
movlw 0x00
movwf DDATA
call Write7219 ;write in 0c00H, shut down MAX7219.
call Delay1ms ;wait leaest 250us.
movlw 0x09
movwf DCOMMAND
movlw 0x3f
movwf DDATA
call Wr ite7219 ;write in 091fH, digits 0 to 5 are transcode.
call Delay1ms
movlw 0x0a
movwf DCOMMAND
movlw 0x0a
movwf DDATA
call Write7219 ;write in 0a0fH, set MAX7219 is the brightest state.
call Delay1ms
movlw 0x0b
movwf DCOMMAND
movlw 0x05
movwf DDATA
call Write7219 ;set SCAN LIMIT is digits 0 to 5.
call Delay1ms
;movlw 0x0f
;movwf DCOMMAND
;movlw 0x00
;movwf DDATA
;call Write7219 ;wirte in 0f00H, exit TEST, go into normal state.
;call Delay1ms
;Begin set Digit Datas
movlw 0x01
movwf DCOMMAND
movlw 0x00
movwf DDATA
call Write7219 ;bit0 is 0
call Delay1ms
movlw 0x02
movwf DCOMMAND
movlw 0x01
movwf DDATA
call Write7219 ;bit1 is 1
call Delay1ms
movlw 0x03
movwf DCOMMAND
movlw 0x02 ;bit2 is 2
movwf DDATA
call Write7219
call Delay1ms
movlw 0x04
movwf DCOMMAND
movlw 0x03 ;bit3 is 3
movwf DDATA
call Write7219
call Delay1ms
movlw 0x05
movwf DCOMMAND
movlw 0x04 ;bit4 is 4
movwf DDATA
call Write7219
call Delay1ms
movlw 0x06
movwf DCOMMAND
movlw 0x05
movwf DDATA
call Write7219 ;bit5 is 5
call Delay1ms
;Begin Display
movlw 0x0c
movwf DCOMMAND
movlw 0x01
movwf DDATA
call Write7219 ;write in 0c01H, exit shut down state.
call Delay1s ;wait for 3 seconds.
;call Delay1s
;call Delay1s
;movlw 0x0c
;movwf DCOMMAND
;movlw 0x00
;movwf DDATA
;call Write7219 ;write in 0c00H, shut down MAX7219.
call Delay1s
return
AddressTable ;list of display data
addwf PCL
retlw 0x0 ;NO-OP
retlw 0x1 ;DIG 0
retlw 0x2 ;DIG 1
retlw 0x3 ;DIG 2
retlw 0x4 ;DIG 3
retlw 0x5 ;DIG 4
retlw 0x6 ;DIG 5
retlw 0x7 ;DIG 6
retlw 0x8 ;DIG 7
retlw 0x9 ;DECODE MODE
retlw 0xa ;INTENSITY
retlw 0xb ;SCAN LIMIT
retlw 0xC ;SHUIDOWN
Write7219
;this function use address 0x0c,0x0d,0x0e,0x0f.
;address 0x0c is data send to MAX7219
;address 0x0d is display command
;address 0x0e is display data
;address 0x0f is cont used
;write address 0x0c to MAX7219 each time
bcf 0x06,2 ;set LOAD is low and MAX7219 begin to recive data
movlw 0x08
movwf 0x0f
movf DCOMMAND,w ;send display address to MAX7219
movwf 0x0c
call SendData
movlw 0x08
movwf 0x0f
movf DDATA,w ;send display data to MAX7219
movwf 0x0c
call SendData
;set a puls from LOAD to MAX7219
bcf 0x06,2 ;LOAD = 0
bsf 0x06,2 ;LOAD = 1
nop ;wait 3 comand times.
nop
nop
bcf 0x06,2 ;LOAD = 0
nop
return
SendData
;this function is used to send data in address 0x0c to MAX7219 from the high
est place.
bcf 0x06,3 ;CLOCK = 0
bcf 0x06,1 ;DATA = 0
btfsc 0x0c,7 ;if bit7 of 0x0c is 0 then skip next command.
bsf 0x06,1 ;DATA = 1
nop
nop
nop ;wait 3 command times.
nop
nop
bsf 0x06,3 ;CLOCK = 1
nop
nop
nop ;delay 5 comand times and clean the Watchdog.
clrwdt
nop
nop
nop
nop
nop
bcf 0x06,3 ;CLOCK = 0
rlf 0x0c,1 ;0x0c move left a bit.
decfsz 0x0f,1 ;0x0f = 0x0f - 1, if x00f = 0 then return to Write7219.
goto SendData
return
Delay1ms
movlw 0x28 ;0x25 = 40D = 28H
movwf 0x0c
delay1ms_loop1
movlw 0x05
movwf 0x0f
delay1ms_loop2 ;40 * 25 = 1000 us = 1ms
clrwdt ;clean watchdog
decfsz 0x0f,1
goto delay1ms_loop2
decfsz 0x0c,1
goto delay1ms_loop1
return
Delay1s
movlw 0xce ;every time use 4.85ms, 1000/4.85=206.1D=CEH
movwf 0x1a
delay1s_loop1
movlw 0x05
movwf 0x1b
delay1s_loop2 ;4.85 ms * 206 = 1 s
clrwdt
call Delay1ms
decfsz 0x1b,1
goto delay1s_loop2
decfsz 0x1a,1
goto delay1s_loop1
return
end 
摘自ec66.com

欢迎进入老古论坛进行讨论
[显示技术] 相关文章:
一个液晶显示的数字式电脑温度计
简介:
液晶显示器分很多种类,按显示方式可分为段式,行点阵式和全点阵式。 段式与数码管类似,行点阵式一般是英文字符,全点阵式可显示任何信息, 如汉字、图形、图表等。这里我们介绍一种八段式四位LCD显示器,该显 示器内置驱动器,串行数据传送,使用非常方便。原理图如下图: 下图是长沙太阳人科技开发有限公司生产的4位带串行接口的液晶显示模块SMS0403 的外部引线简图: &nbsp......

DVD标准战引发PC业内斗 HP戴尔攻击Wintel
英特尔微软火速加盟东芝HD-DVD阵营 存储格式大战局势骤变
用电池容量的一半点亮白色LED
高效率的白色LED驱动器
构成便携式快速光脉冲发生器的电路
用颜色指示电压的“彩虹”LED
为微控制器提供振荡器的LED驱动电路
工业设备中LED显示和键盘扫描设计
提供 64 级对数调光的白光 LED 驱动器
 
下一个:[新闻热点]全球手机告急缺源于线路板紧张
简介:
去年国内手机市场曾遭遇手机元器件短缺问题在眼下再度上演,其主要原因是用于手机的环氧树脂印刷线路板供不应求。 回忆去年情景,人们记得当时包括数码相机镜头、TFT-LCD(薄膜电晶体液晶显示器)、晶体振荡器、图像传感器、LCD(液晶显示器)的连接器和控制器等元器件出现短缺,严重影响了手机制造商新机的上市。除了半导体之外,几乎所有的手机核心元器件都出现了供应短缺问题,原因是上游供应商对手机市场增长速度的估计不足,没能向市场足够供货。去年出现的TFT-LCD供货不足的情况在今年已经得到缓解,其供需已经明显趋于平衡。 但如今手机元器件再次出现元器件供应紧缺问题,目前手机PCB(环氧树......
 

上一个:[新闻热点]上海AT&S二厂将在06年8月投产

老古开发网版权所有 2006年9月 asp.Net V2.0 设计:老古
页面缓存:10分钟 执行时间:16毫秒