Step 6Software
1) for the PCBs shown, the LEDs are laid out in a way that is convenient
to the PCB layout, rather than in "correct" bit order. IMO, this is the
way to do things, but it does mean that Row 1 doesn't necessarilly mean
bit 1, or coluimn 3 doesn't mean bit 3. This requires a level of mapping
between the usual row/column addressing and the bits that need setting.
2) Since the same bits are used for anodes and cathodes, the common
(row) connection for some bits can be in the middle of driven (column)
bits. That means you have to shift column bits around depending on whether
they are before or after the row bit for that set of columns.
3) You have to derive output words for both the ioport and the port direction
register.
The attached ASM code for ATtiny11 is a "proof of concept." It's embarassingly
un-optimized and poorly commented, but it's all I've got written so far.
ledmatrix.asm4 KB| « Previous Step | Download PDFView All Steps | Next Step » |










































(I'm not familiar with this processor. My comments are based on the ability to do indexed addressing mode. Index into a table. For example, for the "noadjust" routine, you would have:
TABLE: .byte 0b00100, 0b00010, 0b00001, 0b10000, 0b01000
copy TEMP to index register
load accumulator TABLE,index
copy accumulator to ANODE
...
You can have separate tables for the port and the direction register. The tables can be large (256 bytes for an 8-bit scramble function) without needing a compare for each value possible. The code becomes compact and easy to debug. You can stack tables. For example, one set to give the port/direction drives, and one to do the bit scrambling (used twice: once to scramble the port bits, again to scramble the direction bits)).
Table lookup is the key to fast processing!