OK, here are some more ramblings. I hope I'm further along the siding and the track is in view?? :-) There are some things missing obviously. I still need to figure out how to put the overflow flag somewhere and count how many times it has been set. 1 flag = 1/10th of an hour. Thats basically the counter that I will be displaying on the seven segments.
Anyway, any help is welcomed. I *think* I'm learning something... ;-)
INCLUDE "modedefs.bas"
define OSC 4
TRISA = %00010000
TRISB = %00000000
T0CON = %00101000
ADCON0 = %00011100
ADCON1 = %01111111
CNT var word
Tenths var word
Units var word
Tens var word
Hundreds var word
Thousands var word
Tenthousands vAR WORD
'RB0 = SEG A
'RB1 = SEG B
'RB2 = SEG C
'RB3 = SEG D
'RB4 = SEG E
'RB5 = SEG F
'RB6 = SEG G
'RA0 = DIGIT1 = TENTHS
'RA1 = DIGIT2 = UNITS
'RA3 = DIGIT3 = TENS
'RA5 = DIGIT4 = HUNDREDS
'RA6 = DIGIT5 = THOUSANDS
'RA7 = DIGIT6 = TENTHOUSANDS
Start:
READ 0,CNT ' Read location 0 and put result into CNT
'(should this be a hi and low)
IF CNT = 0 THEN
SetTimer
ENDIF
If CNT => 1 then '?? i want to put this value into the incremental display
'counter and start counting from this point
endif
'Segment Test LIGHTS ALL SEGMENTS FOR 1SEC
PORTA = %1111011
PORTB = %0111111
PAUSE 1000
PORTA = %0000000
PORTB = %0000000
On Interrupt goto CounterA
SetTimer:
T0CON.0=0 ' Stop the Clock
TMR0H=$AB ' Set Timer Highbyte
TMR0L=$A0 ' Set Timer Lowbyte
T0CON.1=1 ' Restart the Clock
resume
CounterA:
DISABLE
' Interuptable code goes here?
' This is the incremental aspect of the program.
' Any value here is displayed on the segments.
Gosub SetTimer ' Set the Timer for next count
Tenths=Tenths+1 ' Increment 1/10TH minute Counter
If Tenths>9 then
Tenths=0
Units=Units+1 ' Increment the Units
If Units>9 then
Units=0
Tens=Tens+1 ' Increment the Tens
If Tens>9 then
Tens=0
Hundreds=Hundreds+1 ' Increment the Hundreds
If Hundreds>9 then
Hundreds=0
Thousands=Thousands+1 'Increment the Thousands
If Thousands>9 then
Thousands=0
Tenthousands=Tenthousands+1 'Increment the Tenthousands
endif
endif
endif
endif
endif
Resume
' Display code goes here.
End




Bookmarks