Hello there,
I have a new porject where I do use the 74HC595 to switch lines.
Unfortunatley the code doesn't work as expected. Whenever I try turning on a few LEDs the whole line is switched on. But when turning down the power of the LEDs only the wanted LEDs are shining. I was looking at the signal by using a logic analyzer but it looks fine for me there (after every lin there are 32 SCLK flanks with 2 data high on the wanted outputs and afterwards 1 rclk toggle). So did I misunderstand something here?
byte Zeilen [16] [32] = {
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
};
void setup(){
....//only things not referring to 74HC595
}
void loop(){
while(1){
/*Here are still things that don't refer to the 74HC595 */
if (j > 545 && j < 578) {
REG_PIOC_CODR = 0x1 << 25;
if (Zeilen[Zeile][i]) {
REG_PIOB_SODR = 0x1 << 25; //SIN 1
} else {
REG_PIOB_CODR = 0x1 << 25; //SIN 0
}
i++;
REG_PIOC_SODR = 0x1 << 25;
}
switch (j) {
case 577:
REG_PIOC_SODR = 0x1 << 22; //XLAT HIGH (Data Latch)
REG_PIOB_SODR = 0x1 << 25; // CLEAR SIN Zeilentreiber
REG_PIOC_CODR = 0x1 << 25; //Clear SCLK
REG_PIOC_SODR = 0x1 << 26; //RCLK Takt nach jeder neuen Zeile
i = 0;
Zeile ++;
if (Zeile == 16) {
Zeile = 0;
a = 0;
}
REG_PIOC_CODR = 0x1 << 22; //XLAT LOW
REG_PIOC_CODR = 0x1 << 23; //BLANK LOW (GCLK Counting)
REG_PIOC_CODR = 0x1 << 26; //RCLK LOW
break;
//**** 690 - 578 = Anzahl GCLK Takte****//
case 722:
REG_PIOC_SODR = 0x1 << 23; //BLANK HIGH
j = 0;
break;
default: break;
}
j++;
}
}