Hi,
I am able to hook up and control the 8x8 matrix led with an ATMEGA8 and the ST M74HC595, which can gives 8 output at once. I am hoping people here have some HC595 experience. My circuit is 5V DC and my ATMEGA8 is running at 1Mhz, the default clock. I am able draw the rows of dots without any problem. The problem is when my row’s data has a zero in it, suddenly all the output bits messed up. For example, 11111111 (binary) will display fine, but something like 11100111 will not show the row light up correct. The zeros (unlighted LEDs) in the row would be somewhere else. I have spent so much trying to figure it out.
Below is the routine that would draw an 8x8 pattern onto the 8x8 matrix led. Each clock (count) of the 4017 will turn on a column and then I attempt to light up each dot in the column (by traversing the rows) with the help of the HC595.
At HC4017 (decade counter) is driven by my ATMEGA8.
Thanks for any help! Much appreciated.
void drawPattern(int i) {
uint8_t j, k;
// Clear for shifting.
resetHC595(); // LOW on the shift clock. And LOW in the HC595 Serial-in pin.
// and LOW on the latch clock.
// Reset the HC4017
resetHC4017(); // make sure to scan from the first column onward.
// Upon reset, output zero of the HC4017 will be
// HIGH. Note that we don’t use output zero of
// the the HC4017.
// TODO: This does not seem to help.
// Because a reset will trigger Output 0 to high on the HC4017, and we
// are not using/connected to output 0, we need to output a LOW signal
// to it. Our next HIGH clock would advance to output 1 and so on.
clockLowHC4017();
for (j = 0; j < 8; j++) {
// This clock signal is the output to pin 1 of the HC4017 to
// initiate one count. Each count, we will draw the entire pixels
// in a row.
clockHighHC4017();
// Shift out 8 bits–LSB first
uint8_t data = LETTERS*[j];*
for (k = 0; k < 8; k++) {
// Must go from LOW to HIGH in order to shift a bit
// into a shift register.
clockLowHC595();
// load the bit into the 595’s serial-in pin ready for shifting.
if ((data & 0x80) == 0x80) {
loadBit(1);
}
else {
loadBit(0);
}
clockHighHC595();
// Next bit in the data
data <<= 1;
}
// This HIGH to LOW will not affect the shift register, basically
// completing the last clock pulse. Ready to output the 8 bits.
clockLowHC595();
// Now output the 8 bits from the shift register by setting the
// HC595’s latch pin to HIGH!
setHC595Latch();
resetHC595Latch();
clockLowHC4017();
// TODO: Must calculate this base on the Mhz, so that you can
// delay precisly the # of ms.
// 320-350 => 1Mhz
delay_ms(320);
}
}