积分规则 网站地图 帮助中心    
嵌入式软件 单 片 机 DSP 存储器 传感控制 光电显示
嵌入式硬件 CPLD/FPGA SOPC AD/DA 接口电路 模拟设计
I C设计 通信产品 汽车电子 电源产品 消费电子 数控系统
工业控制 军工/航天 安防产品 医疗电子 计算机外设 测试测量
供应 I C
求购 公司库

  IC 求购 销售 公司 论文 DATASHEET 参考设计 论坛
当前位置: 电子技术 >> 嵌入式软件 >> 汇编
  相关分类: LINUX | WINCE | UC/OS | Bootloader | 下载 | VXWORKS | 网络协议 | JAVA | 汇编 | 驱动设计 | Symbian | XP Embedded | Nucleus | 新产品 | 相关文章 | 综合技术 |
16c54四位LED时钟显示程序
 
作者:未知   来源:本站原创    点击数:77   更新时间:2008-7-18
您可以添加到网摘 让更多人关注此文章:

    title"clock"
list p=16c54,n=66
PIC54 equ 1ffh
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;四位LED时钟显示程序 ;;
;;RB1-SW1秒设置 RB2-SW2分设置 RB3-SW3时设置 ;;
;;RB1--RB7接LED段码,RA0--RA3做选通 ;;
;;使用4M晶振TMR0滪分频为1:16 TMRO的循环时间为4.096MS 244次为一秒 ;;
;;用sec_nth计数 ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pointer equ 00h
rtcc equ 01h
pc equ 02h
status equ 03h
fsr equ 04h
port_a equ 05h
port_b equ 06h
;---------------------------------
carry equ 0
c equ 0
dcarry equ 1
dc equ 1
z_bit equ 2
z equ 2
p_down equ 3
pd equ 3
t_out equ 4
to equ 4
pa0 equ 5
pa1 equ 6
pa2 equ 7
;---------------------------------
zero equ 0x7e
one equ 0x0c
two equ 0xb6
three equ 0x9e
four equ 0xcc
five equ 0xda
six equ 0xfa
seven equ 0x0e
eight equ 0xfe
nine equ 0xce
colon equ 0x01
t equ 0xf0
blank equ 0x00
;-----------------------------------------
maxnths equ 0x0c ; d12
maxsecs equ 0xc4 ; d196
maxmins equ 0xc4 ; d196
maxhrs equ 0xf4 ; d244
minhrs equ 0xf3 ; d243
adjmin equ 0x09 ; d9
adjhr equ 0x22 ; d34
adjday equ 0x03 ; d3
;-----------------------------------------------
disp1 equ b'11111110' ;pa0--pa3
disp2 equ b'11111101'
disp3 equ b'11111011'
disp4 equ b'11110111'
dispoff equ b'11111111'
switch equ b'00001110' ;key in portb
;---------------------------------------------
sec equ 00h ;秒 flags d0--d7
min equ 01h ;分
hrs equ 02h ;时
chg equ 03h ;有显示或按键按下
sw1 equ 04h ;
sw2 equ 05h ;
sw3 equ 06h ;
sw_on equ 07h ;有键按下
;------------------------------------
keys equ 08h ;哪个键按下?
flags equ 09h ;the bits for :sec d0. min d1 .hrs d2.chg ;d3.sw1.sw2.sw3 d6 .swon d7
display equ 0bh ;new display
digit1 equ 0ch ;a0
digit2 equ 0dh ;a1
digit3 equ 0eh ;a2
digit4 equ 0fh ;a3 led
;---------------------------------------
sec_nth equ 10h ;秒计数单元
seconds equ 11h ;秒
minutes equ 12h ;分
hours equ 13h ;时
var equ 14h ;运算变量
count equ 15h
count1 equ 16h

start
movlw 0x03
option
movlw 0
tris port_a
tris port_b
movlw blank
movwf port_b
bcf status,pa1
bcf status,pa0
;----------------------------------------
movlw 0x01
movwf rtcc
movlw 0xfe
movwf display
movlw blank
movwf digit1
movwf digit2
movwf digit3
movwf digit4
movlw maxnths ;d12
movwf sec_nth
movlw maxsecs ;d196
movwf seconds
movlw maxmins
movwf minutes
movlw 0xff
movwf hours
movlw 00h
movwf flags
main

rtcc_fill
movf rtcc,0
btfss status,z
goto rtcc_fill
incfsz sec_nth,1
goto time_done
movlw maxnths
movwf sec_nth
check_sw
btfss flags,sw_on
goto set_time
btfsc flags,sw1
goto set_time
movlw maxsecs ;d196
movwf seconds
movlw 0x7f
movwf sec_nth
btfss flags,sw2
goto hourset
movlw 0xaf
movwf sec_nth
incfsz minutes,1
goto hourset
movlw maxmins ;d196
movwf minutes
hourset
btfsc flags,sw2
goto check_time
incfsz hours,1
goto check_time
movlw maxhrs
movwf hours
goto check_time
set_time
bsf flags,sec
bsf flags,chg
incfsz seconds,1
goto time_done
movlw maxsecs
movwf seconds
bsf flags,min
bsf flags,chg
movlw adjmin
subwf sec_nth,1
incfsz minutes,1
goto time_done
movlw maxmins ;0xc4
movwf minutes
bsf flags,hrs
bsf flags,chg
movlw adjhr ;0x22
addwf sec_nth
incfsz hours,1
goto time_done
movlw maxhrs ;0xf4
movwf hours
movlw adjday ;0x03
subwf sec_nth,1
time_done
btfss flags,chg
goto cycle
check_seconds
btfss flags,sw1
goto check_time
movlw 0x00
movwf digit2
movwf digit3
movwf digit4
movlw maxsecs ;0xc4
subwf seconds,0
movwf digit1
goto split_hex
check_time
movlw 0x00
movwf digit2
movwf digit4
movlw minhrs ;0xf3
subwf hours,0
movwf digit3
movlw maxmins ;0xc4
subwf minutes,0
movwf digit1
split_hex
movlw 0x02
movwf count
movlw digit1
movwf fsr
goto loop
loop2
movlw digit3
movwf fsr
loop movlw 0x0a
subwf pointer,1
btfsc status,c
goto increment_10s
addwf pointer,1
goto next_digit
increment_10s
incf fsr,1
incf pointer,1
decf fsr,1
goto loop
next_digit
decfsz count,1
goto loop2
convert_hex_to_display
movlw digit1
movwf fsr
movlw 0x04
movwf count
next_hex
movf pointer,0
call return_code
movwf pointer
incf fsr,1
decfsz count,1
goto next_hex
fix_display
movlw zero
subwf digit4,0
btfss status,z
goto fix_sec
movlw blank
movwf digit4
fix_sec
btfss flags,sw1
goto clear_flags
movwf digit3
clear_flags
movlw 0xf0
andwf flags,1
cycle
movlw dispoff
movwf port_a
movlw switch
tris port_b
movlw 0x0f
andwf flags,1
nop
nop
nop
movf port_b,0
movwf var
btfss var,1
goto switch2
bsf flags,chg
bsf flags,sw1
bsf flags,sw_on
switch2
btfss var,2
goto switch3
bsf flags,chg
bsf flags,sw2
bsf flags,sw_on
switch3
btfss var,3
goto switch3
bsf flags,chg
bsf flags,sw3
bsf flags,sw_on
setport
movlw 0x00
tris port_b
movlw blank
movwf port_b
btfss display,0
movf digit4,0
btfss display,1
movf digit3,0
btfss display,2
movf digit2,0
btfss display,3
movf digit1,0
movwf port_b
btfsc sec_nth,7
bsf port_b,0
movf display,0
movwf port_a
movwf display
rlf display,1
bsf display,0
btfss display,4
bcf display,0
goto main
return_code
addwf pc,1
retlw zero ;0
retlw one
retlw two
retlw three
retlw four ;4
retlw five
retlw six
retlw seven
retlw eight
retlw nine ;9
org PIC54
goto start


end



相关文章
· 白光LED电源设计技术[49]
· LED奥运会大放光芒 功率型芯片基本进口[102]
· 容纳两个DC/DC升压转换器的微控制器[151]
· 采用混合信号高电压单片机实现LED降压-升压驱动电路[78]
· 基于STC单片机与GPRS的图文LED屏[60]
热门评论排行
·VHDL设计中电路简化问题的
·江苏嵌入式Linux教育培训
·锐极LINUX驱动培训班定于
·基于实时操作系统μC/OS-
·ARM处理器应用开发4步骤

文章评论
    没有任何评论
*只显示最新10条评论。评论内容只代表网友观点,与本站立场无关。更多评论
发表评论
  * 请先[登陆]再进行评论,谢谢。
评分: 1分 2分 3分 4分 5分
内容: *
发帖须知:
一.所发文章必须遵守《互联网电子公告服务管理规定》;
二.严禁发布供求代理信息,公司介绍,产品信息等广告宣传信息;
三.严禁恶意重复发帖;
四.严禁对个人,实体,民族,国家等进行漫骂,污蔑,诽谤。
 
热点新闻 [更多]
 
中嵌联盟嵌入式工程师俱乐部"
e-Shuttle与香港科技园携手
美国国家半导体推出业界首个传感器信号
PAC 2008 
Power Archite
2008上半年中国集成电路市场回顾
日本开发出接近人眼功能的新型电荷耦合
2008上半年中国集成电路市场回顾
Intersil公布产品线重组计划,
IBM进军15纳米芯片领域
 
热门下载 [更多]
 
[ PCB设计] Protel99教程下载
[ ] 手把手学单片机20个例
[ ] 单片机做的智能台灯
[ ] 单片机入门书
[ ] linux系统移植开发文档
[ ] IC卡的读写程序
[ ] 8051单片机C语言彻底应用
[ 常用软件] 555定时器电路设计软件V1.2
[ 常用软件] 51定时器计算软件
[ ] ARM处理器应用开发4步骤
 
论坛新帖 [更多]
 
高级射频工程师(猎头职务-珠海...
[推荐]通讯上通用的一个GSM...
[推荐]ARM培训视频-dsp...
[原创]差压式流量计的精度分析...
[原创]差压式流量计的精度分析...
[转帖]:FPGA与PCB板焊...
[转帖] 美国锐拓(Ridge...
〓特区〓功率模块IGBT、帮兄...
[求助]请问大家有可以烧录大于...
[求助]请问大家有可以烧录大于...

 
赞助商 [更多]
 

ICP许可证号:[粤 05056597]
联系电话:010-82517432 82517615 传真: 010-82517615

版权所有 Copyright © 2006 嵌入式技术网