Hello,
I will assume that you require to directly drive each display digit, without multiplexing. You will therefore require a total of 14 pins, or 16 pins if you also requre DP connections. I would suggest to use Port B for one of the digits, and Port C connections for the other digit.
The code will be slightly simpler if you have identical segment layout for each digit, since you will require to have a look-up table to convert the BCD value for each digit to drive the required display segments. With the same segment layout, a single table would cater for both digits. The size of the table will be 10 bytes, to represent the values 0 through 9.
On this basis, you cannot use Port B as a counter register - you will need to define a separate variable in RAM for this purpose. This should preferably be allocated within zero-page RAM, so that the INC instruction can be used to directly increment.
To display the current counter value, you will need to convert the binary counter value to two BCD values, before using the look-up table. Consider the following code snippet -
; 7-segment look-up table
TABLE:
DC.B ...
SHOW_COUNT:
LDA COUNTER
; Commence binary to BCD conversion
CLRH
LDX #10
DIV
PSHH ; Save LS digit to stack
; Display the result
TAX ; MS digit value (0-9)
CLRH
LDA TABLE,X ; Fetch 7-segment value
STA PTCD ; Display MS digit
PULX
LDA TABLE,X ; Fetch 7-segment value
STA PTBD ; Display LS digit
RTS
I have not shown the contents of the look-up table, as this will depend on the allocation of segment, and whether common anode, or common cathode displays are used.
You will require a current limiting resistor in series with each display segment. To prevent over-stressing the device, the current should be limited to 5 mA per segment. If you need greater segment current, external buffers will be needed, possibly using multiple Darlington transistor buffers (with 7 or 8 per package).
The number of MCU pins required can be significantly reduced to about three pins when the display digits are driven by external shift register packages (e.g. 74HC595), but this will require more complex code.
Regards,
Mac