Dim digit As Byte 'input variable for GETMASK subroutine
Dim digit1 As Byte 'current high digit
Dim digit2 As Byte 'current low digit
Dim mask As Byte 'output variable from GETMASK subroutine
Dim mask1 As Byte 'current high digit mask
Dim mask2 As Byte 'current low digit mask
Dim i As Byte
Symbol d1enable = PORTA.0 'enable line for higher 7-segment display
Symbol d2enable = PORTA.1 'enable line for lower 7-segment display
TRISA.0 = 0 'set RC0 pin as output
TRISA.1 = 0 'set RC1 pin as output
TRISB = %00000000 'set PORTB pins as outputs Display 1
TRISC = %00000000 'set PORTc pins as outputs Display 2
TRISD = %11111111 'Set port D to input
d1enable = True
d2enable = True
mask1 = 0
mask2 = 0
loop:
For i = 0 To 255
digit1 = ShiftLeft(PORTD, 4) 'Get the lower 4 bits
digit1 = digit1 / 16
digit2 = ShiftRight(PORTD, 4) 'Get the upper 4 bits
digit = digit1
Gosub getmask 'get mask for high digit
mask1 = mask
digit = digit2
Gosub getmask 'get mask for low digit
mask2 = mask
Gosub show 'display new mask
'delay interval suitable for simulation
'use large delay for the real device, say WAITMS 500
Next i
Goto loop
End
getmask: 'get appropriate 7-segment mask for input digit
mask = LookUp(0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71), digit
Return
show:
PORTB = mask1
PORTC = mask2
Return