Number of LEDs and matrix
dimensions: The matrix dimension determines the number of GPIO pins
needed to run the matrix. For example, a 16 LED matrix can use 8 pins in a 4 × 4
matrix or 10 pins in a 2 × 8 matrix.
LED configuration: The
active states of the row and column pins is dependent on whether the matrix is
in common row cathode or common row anode.
Column pin values: Column
pin values are set in a memory table. The exact values are determined by which
pins are selected and the respective column mask. For ease of setup, selecting
pins that are in numerical order with no gaps is the easiest.
Column and row pin
connections: When connecting pins to the LED matrix, application
programming is easiest if the row pins start from the topmost row (moving down)
and the column pins start from the right-most column (moving left).
Timer interrupts: The
speed of the interrupts affects the display period and how long each row of LEDs
is on per the state machine cycle. This specific example interrupts every 5ms,
preventing the human eye from noticing any flickering.
Updating the memory table:
The specific method of updating the memory table depends on the application.
This example increments a counter (otherwise known as the display period) up to
a specified value. When the counter reaches that value, the memory table is
updated to set a new display.