common cathode matrix 8x10

My new midibox-based project need duo-led+button 8x10 matrix.

In attached file scheme of matrix. This scheme is correct?

The minimum elements is necessary.

I would advise not to use ULN2003A (i.e. darlington transistor array). When these are fully sinking current, the voltage at the collector (i.e. collector-emitter voltage) when fully saturated MAY BE higher than the logic level low voltage of the 74HC165. This is why I used discrete BC547 transistors in the MB-6582 - 1K resistor between output pin and BC547 base, collector to common cathode “row”, emitter to ground.

Here my main.c, it is compiled without errors.

This code is correct? I wish to know it before PCB creation.

I badly understand a principle of operation of function SR_Service_Prepare.

P.S. I have project in Proteus, but i don’t know how to load MIOS+application in virtual PIC.

[main.c](< base_url >/applications/core/interface/file/attachment.php?id=7145)