英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流

 找回密码
 立即注册
搜索
电子烟方案单片机单片机开发深圳单片机开发
单片机方案国产单片机8位单片机电子烟方案开发
查看: 2756|回复: 0
打印 上一主题 下一主题

PIC16F877A单片机led的动态显示

[复制链接]
跳转到指定楼层
1#
发表于 2009-5-5 17:24:46 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
list p=16F877A,R=DEC
include "p16F877A.inc"
;;;;;user variables;;;;;;;;
Count2 equ 23H
Count3 equ 24H
data_out1 equ 25H
data_out2 equ 26H
;;;;;;;reset vector;;;;;;;;;
org 0x00
goto mainline
;;;;;;delay program;;;;;;;
delay_2ms
movlw 0x05
movwf Count2
lp0 movlw 0xff
movwf Count3
lp1 decfsz Count3,F
goto lp1
decfsz Count2,F
goto lp0
return delay_250ms
movlw 0x41
movwf Count2
movlw 0xff
movwf Count3
decfsz Count3,F
goto $-1
decfsz Count2,F
goto $-5
movlw 0xff
movwf Count2
movlw 0xff
movwf Count3
decfsz Count3,F
goto $-1
decfsz Count2,F
goto $-5
return
;;;;;;main program;;;;;;;;;
mainline
banksel TRISA
movlw 0x00
movwf TRISA
movlw 0xff
movwf TRISB
movlw 0x00
movwf TRISC
movwf TRISD
movwf TRISE

banksel PORTA
movlw 0x00
movwf PORTA
movwf PORTB
movwf PORTC
movwf PORTD
movwf PORTE
banksel INTCON
bcf INTCON,PEIE
lp
btfsc PORTB,0
goto lp
call delay_250ms
wait1
btfss PORTB,2
goto led1
btfss PORTB,3
goto led2
goto wait1
lp2
movf PORTA,W
movwf data_out1
L2
btfsc PORTB,1
goto L2
call delay_250ms
wait2
btfss PORTB,2
goto led3
btfss PORTB,3
goto led4
goto wait2
led1
call delay_250ms
movlw 0x00
movwf PORTA
movlw 0x01
movwf PORTA
movlw 0xfe
movwf PORTC
goto lp2
led2
call delay_250ms
movlw 0x00
movwf PORTA
movlw 0x02
movwf PORTA
movlw 0xfe
movwf PORTC
goto lp2
led3
call delay_250ms

movlw 0x01
movwf PORTA
movlw 0xfd
movwf PORTC
call delay_2ms

banksel PORTC
movlw 0x00
movwf PORTC
movlw 0xfe
movwf PORTC
movf data_out1,W
movwf PORTA

call delay_2ms
call delay_2ms

led4
call delay_250ms

movlw 0x02
movwf PORTA
movlw 0xfd
movwf PORTC
call delay_2ms

banksel PORTC
movlw 0x00
movwf PORTC
movlw 0xfe
movwf PORTC
movf data_out1,W
movwf PORTA

call delay_2ms
end
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|公司首页|Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 ( 粤ICP备09008620号 )

GMT+8, 2024-11-24 06:44 , Processed in 0.050374 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表