Hi
or you can use it with controlling on the enable bit of the seven segment send like this
program seven_seg_counting
dim i as byte
dim j as byte
dim v as byte
dim por1 as byte
dim por2 as byte
' This function returns masks
' for common cathode 7-seg display
sub function mask(dim num as byte) as byte
select case num
case 0 result = $3F
case 1 result = $06
case 2 result = $5B
case 3 result = $4F
case 4 result = $66
case 5 result = $6D
case 6 result = $7D
case 7 result = $07
case 8 result = $7F
case 9 result = $6F
end select
end sub
sub procedure interrupt
if v = 0 then
PORTB = por2 ' Prepare mask for digit
PORTA = 1 ' Turn on 1st, turn off 2nd 7seg
v = 1
else
PORTB = por1 ' Prepare mask for digit
PORTA = 2 ' Turn on 2nd, turn off 1st 7seg
v = 0
end if
TMR0 = 0
INTCON = $20
end sub
main:
OPTION_REG = $80
por2 = $3F
j = 0
TMR0 = 0
INTCON = $A0 ' Disable PEIE, INTE, RBIE, T0IE
TRISA = 0
TRISB = 0
PORTB = 0
PORTA = 0
do
for i = 0 to 99 ' Count from 0 to 99
' Prepare ones digit
j = i mod 10
por1 = mask(j)
' Prepare tens digit
j = (i div 10) mod 10
por2 = mask(j)
Delay_ms(1000)
next i
loop until false
end.
this program was written in mikrobasic to count from 00 to 99