How to connect two devices to same SPI line (TPIC6B595 + LCD ST7920)

I'm trying to connect the shift register TPIC6B595 and LCD ST7920 to the SPI line to spare some pins.
But when both connected none will work, if i disconnect one or another it work alone. Obvious because they are connected to same lines without any pre selection. I'm not sure how to use SPI yet, the I2C are lot easier since it work with addresses, but what about the SPI? I read somewhere it need a EN (Pin enable or selector) but not sure how to wire or program this since the shift register haven't EN pin.
Is it possible to wire this both together?

Code sample:

#include <SPI.h>
#include <U8g2lib.h>

#define LCD_RESET      9  //reset

U8G2_ST7920_128X64_1_HW_SPI lcd(U8G2_R2, SCK, LCD_RESET); //Enable, RW, RS, RESET  

void setup() {
  // put your setup code here, to run once:
  pinMode (SS, OUTPUT);
SPI.begin(); // library takes care of D11,12,13



lcd.firstPage();
  do {
    lcd.setFont(u8g2_font_unifont_t_symbols);
    lcd.drawStr(8, 16, "Smoke Absorver");
    lcd.drawStr(16, 36, "Version: 10");
    lcd.drawFrame(0, 0, 128, 64);
    lcd.drawFrame(2, 2, 124, 60);
  } while (lcd.nextPage());

}

void loop() {
  // put your main code here, to run repeatedly:
// say 4 devices being used
digitalWrite (SS,LOW);  // SS (D9)goes to SRCK PIN on all devices
SPI.transfer(B00000001);  // SCK (D13) goes to clock pin on all devices
digitalWrite (SS,HIGH);  // outputs update on this rising edge
 delay(1000);

 digitalWrite (SS,LOW);  // SS (D9)goes to SRCK PIN on all devices
SPI.transfer(B00000100);  // SCK (D13) goes to clock pin on all devices
digitalWrite (SS,HIGH);  // outputs update on this rising edge
 delay(1000);

}

Have you been here yet? SPI - Arduino Reference Your answer is within.

Along with a lot more information that you might need soon.

Delta_G:
Have you been here yet? SPI - Arduino Reference Your answer is within.

Along with a lot more information that you might need soon.

I have but theres one thing that still confuse me

SS (Slave Select) - the pin on each device that the master can use to enable and disable specific devices.

If i have to use the SS pin to disable and enable devices to comunicate with, and atmega328p only have one SS pin that mean i can only control 1 device without any other parts like a decoder?

No, you gotta actually read the whole page. You can't just read the first little bit and think you have it figured out.

Read down to the section labelled Note About Slave Select pin on AVR based boards. Last paragraph before the examples. But don't just read that one bit to get this answer. Read the whole page. It's full of info you'll need.

Delta_G:
No, you gotta actually read the whole page. You can't just read the first little bit and think you have it figured out.

Read down to the section labelled Note About Slave Select pin on AVR based boards. Last paragraph before the examples. But don't just read that one bit to get this answer. Read the whole page. It's full of info you'll need.

Thank you for point me out.
I have changed my code and wiring, still i got same effect but now shift register won't work :frowning:
Have changed shift register G to D9 and LCD EN to D8.
LCD backlight keep blinking without any text (caused by loop)
What i'm doing wrong?

#include <SPI.h>
#include <U8g2lib.h>

#define LCD_RESET      8  //reset

U8G2_ST7920_128X64_1_HW_SPI lcd(U8G2_R2, SCK, LCD_RESET); //Rotation, Clock, RESET  

void setup() {
  // put your setup code here, to run once:
  pinMode (9, OUTPUT);
SPI.begin(); // library takes care of D11,12,13
}

void loop() {
  // put your main code here, to run repeatedly:
// say 4 devices being used
digitalWrite (9,LOW);  // SS (D9)goes to SRCK PIN on all devices
SPI.transfer(B00000001);  // SCK (D13) goes to clock pin on all devices
digitalWrite (9,HIGH);  // outputs update on this rising edge
 delay(1000);

 digitalWrite (9,LOW);  // SS (D9)goes to SRCK PIN on all devices
SPI.transfer(B00000100);  // SCK (D13) goes to clock pin on all devices
digitalWrite (9,HIGH);  // outputs update on this rising edge
 delay(1000);


 lcd.firstPage();
  do {
    //lcd.setFont(u8g2_font_ncenB14_tr);
    //lcd.drawStr(0, 24, "Smoke Absorver " VERSION " ");
    lcd.setFont(u8g2_font_unifont_t_symbols);
    lcd.drawStr(8, 16, "Smoke Absorver");
    lcd.drawStr(16, 36, "Version: 10");
    lcd.drawFrame(0, 0, 128, 64);
    lcd.drawFrame(2, 2, 124, 60);
  } while (lcd.nextPage());
}

You have to give them all different SS pins. Each device needs it's own pin for SS. If you still think you only have one option for SS, then go read that again.

Delta_G:
You have to give them all different SS pins. Each device needs it's own pin for SS. If you still think you only have one option for SS, then go read that again.

no, i have given different pins now

LCD SS -> SS
Shift Register SS -> 7

Can be that way? Because is not working to me

ok i able to fix it, belive or not i haven't tie the arduino GND to breadboard GND line, strange fact is that LCD had backlight and LED blink when tied to breadboard GND, hows that possible if all conections to GND was not connected?