Hello all,

I've been working on a project that uses a 16f877a to display some data on some multiplexed 5x7 matrix displays. It's working OK, but I was hoping there was a better way of doing this.

Right now I have the rows driven with bits 0..6 of port B and D (bi-color displays), but the columns are driven with all the leftover pins:
ColA var portd.7
ColB var porte.0
ColC var porta.5
ColD var portc.5
ColE var portc.3
ColF var portc.4
ColG var portb.7
ColH var portc.0
ColI var porte.2
ColJ var porte.1

I'm using a timer interrupt to handle the actual multiplexing:
ISR:

branch currentcol, [INT0,INT1,INT2,INT3,INT4,INT5,INT6,INT7,INT8,INT9]
INT0: 'activate colA only
high colj 'turn off the last column
portb = greendata[0] | %10000000 'mask out the high bit, it controls a colunm drive
portd = reddata[0] | %10000000 'mask out the high bit, it controls a colunm drive
low colA ' turn on new column
currentcol = 1
GOTO INTEND

INT1: 'activate colB only
high cola 'turn off the last column
portb = greendata[1] | %10000000
portd = reddata[1] | %10000000
low colb
currentcol = 2
goto intend

>eight more snipped, you get the idea<

INTEND:
tmr0 = 57
intcon.2 = 0

Resume

Originaly I tried a select case structure for this, but I found that the different cases took different amounts of time to proccess. That led to a very noticable brightness variation accross the display. To counter that I added a different size pause to each case. (as much as 70us). Not suprisingly, performance was kinda crappy :-)

Eventualy I turned to this branch structure, it doesn't have the brightness problem, it runs faster (about 40us, for all cases) and took less code (>80 words less), but it's still ugly. I was hoping for somthing more like:

ISR:
CurrentColumn = CurrentColumn + 1
'add some if-then bounds checking here...

HIGH (CurrentColumn - 1 )
portb = greendata[CurrentColumn] | %10000000
portd = reddata[CurrentColumn] | %10000000
LOW CurrentColumn

tmr0 = 57
intcon.2 = 0

Resume

I know it doesn't work exactly like this, but I was hoping someone might have a way of grouping various pins into an array or something such? (or some other better way to solve this)

Thanks,
-Denny