/\/\/\
I've modified it so that it no longer uses the interupt, but just loops and adds 1 at each loop.
Its also modified to display on 5 displays, and I will add a 6th shortly. It currently ghosts the numbers on each digit. I played with the timing and cant resolve the problem. Also, what are the CON numbers doing, as I changed them and get different results based on their number? There are 10K pull downs on each base and every segment. There 4.7K's between the pic and the base of each 2n3906.
Here is my code so far using a 16F818.......
define OSC 10
TRISA = %11100000
TRISB = 0
data @0,192,249,164,176,153,146,130,248,128,144 ' table to convert
' numbers to 7 segments
DisplayPort var PORTB ' Port for 7 Segments
ClockInput var PORTA.5 ' Input pin for signal
_7Seg0 con 5 ' enable tenthousands 7 segment display
_7Seg1 con 4 ' enable thousands 7 segment display
_7Seg2 con 3 ' enable hundreds 7 segment display
_7Seg3 con 2 ' enable tens 7 segment display
_7Seg4 con 1 ' enable units 7 segment display
Digit_0 var word ' tenthousands digit
Digit_1 var word ' thousands digit
Digit_2 var word ' hundreds digit
Digit_3 var word ' tens digit
Digit_4 var word ' Unit digit
ToBeDisplay var word ' Result of count
Display var word ' Temp variable
DisplayLoop var word '
Delay var word ' Variable for Delay loop
OverFlowVar var word '
Thousands var bit ' Flag for count >= 1000 & < 10 000
TenThousands var bit ' Flag for count >= 10 000
tobedisplay = 0 ' set initial value of count
DisplayRefresh:
' convert digit to 7 segment output pattern
' -----------------------------------------
display=ToBeDisplay dig 4 ' Read tenthousands digit
read display,digit_0 ' Convert tenthousands
if thousands==1 then digit_0=digit_0 & $7F ' enable decimal dot
' by clearing PORTB.7
display=ToBeDisplay dig 3 ' Read thousands digit
read display,digit_1 ' Convert thousands
if thousands==1 then digit_1=digit_1 & $7F ' enable decimal dot
' by clearing PORTB.7
display=ToBeDisplay dig 2 ' Read hundreds digit
read display,digit_2 ' Convert hundreds
if thousands==1 then digit_2=digit_2 & $7F ' enable decimal dot
' by clearing PORTB.7
display=ToBeDisplay dig 1 ' Read tenths digit
read display,digit_3 ' Convert tenths
if tenthousands==1 then digit_3=digit_3 & $7F ' enable decimal dot
' by clearing PORTB.7
display=ToBeDisplay dig 0 ' Read units digit
read display,digit_4 ' Convert units
'
'
' Send digit to 7 segments
' ------------------------
for displayloop = 1 to 53
' display tenthousands
' ----------------
PORTA=_7seg0 ' enable tenthousands 7 segment
displayport=digit_0 ' display
gosub DelayBetweenEachDigit
' display thousands
' ----------------
PORTA=_7seg1 ' enable thousands 7 segment
displayport=digit_1 ' display
gosub DelayBetweenEachDigit
' display hundreds
' ----------------
PORTA=_7seg2 ' enable hundreds 7 segment
displayport=digit_2 ' display
gosub DelayBetweenEachDigit
' display tenth
' -------------
PORTA=_7seg3 ' enable tenth 7 segment
displayport=digit_3 ' display
gosub DelayBetweenEachDigit
' display units
' -------------
PORTA=_7seg4 ' enable unit 7 segment
displayport=digit_4 ' display
gosub DelayBetweenEachDigit
next
tobedisplay = tobedisplay + 1
goto displayrefresh
DelayBetweenEachDigit:
for delay=1 to 307
@ nop
next
@ nop
@ nop
@ nop
@ nop
@ nop
@ nop
@ nop
return




Bookmarks