74HC595 problem

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++;
}
}

Pointless posting code, when we have no idea what the schematic is.

.

ieee488:
Pointless posting code

And when it is pure garbage. This code has nothing to do with 74hc595. You might as well post the script for "Othello" into the IDE. At least that would be worth reading.

You need to post all your code as well as the schematic.
This

void setup(){
....//only things not referring to 74HC595

}

Is nonsense, it will contain the pin mode calls for all your output pins driving the shift register.

Awesome thanks for your help!
Instead of giving me some kind of example code for the 74hc595 you simply complain about the code I am really impressed! Will help a lot thank you all!

You are most welcome. You thoroughly deserve all the help we are able to give you. You earned it.

Let me second that comment.
All we asked is for was all your code and not code with big lumps cut out of it. But apparently that is way too much for you to do, so I don’t think you would deserve any help even if you were intelligent to understand it.

Oh I did realize that you wanted all of the code. Unfortunatley I have access to the code only thursdays. In addition you were complaing about my

PaulRB:
...pure garbage. This code has nothing to do with 74hc595.

so I don't really think posting the whole code would help anything.

EDIT: if you want the schematic I do have it in mind.
PIN 2 (PB25) -> Serial in 74HC595
PIN 4 (PC26) -> RCLK (Latch)
PIN 5 (PC25) -> SCLK (Serial clock)
OE I predefined as LOW and I am not touching this.
Same goes for SCLR I pull it on low in the beginning to clear everything and then I let this set to HIGH.