0-99 sayıcı ASM. yardımı isteği

cemal65

Üye
Katılım
5 Nis 2009
Mesajlar
2
Puanları
1
Yaş
58
Selamlar
16f628a kullanarak 0-99 sayıcı devresini yapmak istiyorum ancak; her iki displeyde de 0 (sıfır) gösterdiği anda kulanılmayan herhangi bir bacacaktan bir çıkış almak istiyorum. yani displeylerde '00' haricinde bir değer gösterirken çıkış vermesin istiyorum ancak asembler bilgim yeterli değil ekte gönderdiğim asm. dosyasında ne gibi bir ilave yapmam gerekir . yardımlarınızı bekler teşekkür ederim.

;****************************************************************
;* 2 Digit UP / Down Counter Started 17/6/2009
;Port B drives 7 segment display
;Up sw on RA2 Down on RA3
;Units drive on RA0 Tens drive on RA1 *
;* *
;****************************************************************
LIST P=16F628A ;microcontroller
#INCLUDE "P16F628A.INC" ;registers for F628
__CONFIG _CP_OFF & _LVP_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _MCLRE_OFF
errorlevel -305
;code protection - off
;low-voltage programming - off
;power-up timer - on
;watchdog timer - off
;use internal RC for 4MHz - all pins for in-out
;****************************************************************
; variables - names and files
;****************************************************************

;Files for F628 start at 20h


temp1 equ 20h ;for delay
temp2 equ 21h ;for delay
SwUp equ 22h ;
SwDwn equ 23h ;
units equ 24h ;
tens equ 25h ;
Sw_Flag equ 26h ;
option_reg equ 27h ;
;****************************************************************
;Equates
;****************************************************************
status equ 0x03
cmcon equ 0x1F
rp1 equ 0x06
rp0 equ 0x05
portA equ 0x05
portB equ 0x06
;****************************************************************
;Beginning of program
;****************************************************************
reset org 00 ;reset vector address
goto SetUp ;goto SetUp

table addwf PCL,F ;02h,1 add W to program counter
retlw b'01000000' ; "0" -|F|E|D|C|B|A
retlw b'01111001' ; "1" -|-|-|-|C|B|-
retlw b'00100100' ; "2" G|-|E|D|-|B|A
retlw b'00110000' ; "3" G|-|-|D|C|B|A
retlw b'00011001' ; "4" G|F|-|-|C|B|-
retlw b'00010010' ; "5" G|F|-|D|C|-|A
retlw b'00000010' ; "6" G|F|E|D|C|-|A
retlw b'01111000' ; "7" -|-|-|-|C|B|A
retlw b'00000000' ; "8" G|F|E|D|C|B|A
retlw b'00010000' ; "9" G|F|-|D|C|B|A

;****************************************************************
;* port A and B initialisation *
;****************************************************************
SetUp
bsf status,rp0
movlw b'00001100' ;Make RA0,1 out RA2,3 in
movwf 05h
clrf 06h ;Make all RB output
bcf status,rp0 ;select programming area - bank0
movlw b'10000000' ;Turn off T0CKI, prescale for TMR0 = 1:
movwf option_reg
clrf portB ;Clear Port B of junk
clrf units ;zero the units file
clrf tens ;zero the tens file
clrf Sw_Flag
movlw 07h ;turn comparators off and enable
movwf cmcon ;pins for I/O functions
goto Main


;****************************************************************
;* Delay 10mS 10 x 1,000uS *
;****************************************************************

D_10mS
movlw 0Ah
movwf temp2
D_a
nop
decfsz temp1,1
goto D_a
decfsz temp2,1
goto D_a
retlw 00


Up

btfsc Sw_Flag,2
retlw 00
bsf Sw_Flag,2
incf units,1
movlw 0Ah ;put 10 into w
xorwf units,0 ;compare units file with 10
btfss status,2 ;zero flag in status file. Will be set if units is 10
retlw 00
clrf units
incf tens,1
movlw 0Ah ;put 10 into w
xorwf tens,0 ;compare units file with 10
btfsc status,2 ;zero flag in status file. Will be set if tens is 10
clrf tens
retlw 00 ;display passes 99 but not below 0



Dwn
btfsc Sw_Flag,3
retlw 00
bsf Sw_Flag,3
decf units,1
movlw 0FFh ;put FFh into w
xorwf units,0 ;compare units file with FFh
btfss status,2 ;zero flag in status file. Will be set if units is 10
retlw 00
movlw 09
movwf units ;put 9 into units file
decf tens,1
movlw 0FFh ;put 0FFh into w
xorwf tens,0 ;compare tens file with 0FFh
btfsc status,2 ;zero flag in status file. Will be set if tens is 0FFh
goto $+2 ;tens file is 0FFh
retlw 00
clrf tens
clrf units
retlw 00 ;display not below 0


;****************************************************************
;* Main *
;****************************************************************
Main

btfss portA,2 ;test switch-press for UP
call Up ;UP switch pressed
btfss portA,3 ;test switch-press for Down
call Dwn ;Down switch pressed
movlw b'00000001' ;Make RA0 HIGH for units drive
movwf portA
movf units,0 ;copy unit value into w
call table ;unit display value will return in w
movwf portB ;output units value
call D_10mS ;call delay
clrf portB ;clear display
movlw b'00000010' ;Make RA1 HIGH for tens drive
movwf portA
movf tens,0 ;copy tens value into w
call table ;tens display value will return in w
movwf portB ;output tens value
call D_10mS ;call delay
clrf portB ;clear display
btfsc portA,2 ;bit will be zero when sw is pressed
bcf Sw_Flag,2
btfsc portA,3 ;bit will be zero when sw is pressed
bcf Sw_Flag,3
goto Main

END
 
arkadaşlar yardım edenin yardımları karşılıksız bırakılmayacaktır. Lütfen yardımcı olun, bu konuya hakim arkadaşlara göre bir kaç satır program ilavesiyle çözülebileceğini tahmin ediyorum. "0 0" değeri ile o anki displeylerin değeri karşılaştırılıp sonuç aynı ise bir çıkış verilecek yok aynı değilse herhengi bir işlem olmayacak.
 
a0 ve a1 sürücü pinler yani birinci segment aktif olması için porta'nın 0. biti aktif olmalı aynı şekilde 2. segment için porta'nın 1. biti aktif olmalı bu sayıcı göz aldatma olayı ile çalışır.birinci segmente bir sayı gönderirken kısa bir sürede diğer segmentede gönderip ikiside aynı anda bilgi alıyormuş gibi gösterilir..şimdi yapacağın değişiklik;
porta'nın 0.biti aktif iken portb'deki değer 0x00h mi denetleyeceksin doğru ise bir değişkenin değerini 0x01 yap mesela hemen sonra porta'nın 1. biti aktif iken portb'deki değer 0x00h mi denetleyeceksin doğru ise az önceki değişkende 0x01 ise sayı sıfırdır demektir..
 

Forum istatistikleri

Konular
128,133
Mesajlar
915,308
Kullanıcılar
449,850
Son üye
umutbaysal9

Yeni konular

Çevrimiçi üyeler

Geri
Üst