Skip to main content
Bkris.2
Associate III
January 1, 2022
Question

Communication to parallel (not cascade) 74hc595 over common bus lines

  • January 1, 2022
  • 19 replies
  • 6163 views

Hi Experts,

PFA the hardware design. I am trying to send data to parallel (not cascade) 74hc595 over common bus lines from CD4094B. I am sending 16 bits to place first 8 bits in 74hc595(1) and second bits in 74hc595(2). But I am getting same 8 bits (10101010) on both 74hc595 devices.

Could you please let me know how to send 16 bits such that first 8 bits should place in first 74hc595 and second 8 bits should place in second 74hc595. Please find the code snippet below and let me know if I am missing anything.

CODE::

----------

uint8_t test[16] = {1,1,1,1,0,0,0,0,1,0,1,0,1,0,1,0};

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11, GPIO_PIN_SET); // CD4094 OE

for (int bit=0; bit<16; bit++)

{

   HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET);  //CD4094 STROBE

   output = test[bit] & 1;

   if (output) {

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, GPIO_PIN_SET); //CD4094 DATA

   } else {

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, GPIO_PIN_RESET); //CD4094 DATA 

   }

   HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET); //CD4094 CLOCK

   HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET);  

   HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_SET); // CD4094 STROBE

   HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); // 74hc595 CLOCK

   HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET);  

}

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET); // 74hc595 OE

HAL_Delay(3000);

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET);

HAL_Delay(3000);

Thanks,

Balu

This topic has been closed for replies.

19 replies

MM..1
Super User
January 1, 2022

This is possible only in your dreams.

You need separate latch signal or cascade.

Bkris.2
Bkris.2Author
Associate III
January 1, 2022

Thanks for your reply. Sorry, I missed Q' (pin 9) of 74hc595 connected through common bus to all the 74hc595 in the previous drawn schematic. Please find the full schematic and let me know any suggestions.

Bkris.2
Bkris.2Author
Associate III
January 1, 2022
MM..1
Super User
January 1, 2022

Ahh

your schematics and code is ...

you strobe every bit for CD, but 595 strobe or register signal is RC on serial clock very non standart control.

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_SET); // CD4094 STROBE

this is need only once on all bits send end. Same for 595.

Maybe when you use high speed write to CD and other speed to 595 with proper handle

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET); //CD4094 CLOCK

Bkris.2
Bkris.2Author
Associate III
January 1, 2022

Thanks. I have tried the code to send 8 bits at a time to CD4094 and set the CD4094 STROBE only once in the end. Also I set the CD4094 clock to "high" and 595 clock to "low" and vice versa also. But no data (00000000) is seen on 74hc595. Please find the code below.

uint8_t test[16] = {1,1,1,1,0,0,0,0,1,0,1,0,1,0,1,0};

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11, GPIO_PIN_SET); // CD4094 OE

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET);  //CD4094 STROBE

for (int bit=0; bit<8; bit++)

{

   output = test[bit] & 1;

   if (output) {

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, GPIO_PIN_SET); //CD4094 DATA

   } else {

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, GPIO_PIN_RESET); //CD4094 DATA 

   }

   HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET); //CD4094 CLOCK

   HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET);  

}

   HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_SET); // CD4094 STROBE

for (int i=0; i <8; i++) { 

   HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); // 74hc595 CLOCK

   HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET);  

}

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET); // 74hc595 OE

HAL_Delay(3000);

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET);

HAL_Delay(3000);

MM..1
Super User
January 1, 2022

I dont see any speed and clk change try this

uint8_t test[16] = {1,1,1,1,0,0,0,0,1,0,1,0,1,0,1,0};
 
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11, GPIO_PIN_SET); // CD4094 OE
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET); //CD4094 STROBE
 
for (int bit=0; bit<8; bit++)
{
 output = test[bit] & 1;
 if (output) {
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, GPIO_PIN_SET); //CD4094 DATA
 } else {
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, GPIO_PIN_RESET); //CD4094 DATA 
 }
 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET); //CD4094 CLOCK
 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET); 
}
 
 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_SET); // CD4094 STROBE
 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); // CLOCK
HAL_Delay(3000);
 
for (int i=0; i <8; i++) { 
 output = test[bit+8] & 1;
 if (output) {
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, GPIO_PIN_SET); //CD4094 DATA
 } else {
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, GPIO_PIN_RESET); //CD4094 DATA 
 }
 
 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); // 74hc595 CLOCK
 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET); 
}
  
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET); // 74hc595 OE
  
HAL_Delay(3000);

Bkris.2
Bkris.2Author
Associate III
January 1, 2022

I have modified clock speed in "GPIO Mode and Configuration" tab. Please find the screen shots. For now I tried with PB0 as "high" and PB12 as "medium". Also I tried the same code as you suggested but still same output (00000000).

0693W00000HqIVEQA3.png0693W00000HqIV9QAN.png

MM..1
Super User
January 1, 2022

We cant help you , your pinout is mixed and chaos.

Learn how rising edge works...

How size is C4 ?

Bkris.2
Bkris.2Author
Associate III
January 2, 2022

what is C4? do you mean CD 4094

MM..1
Super User
January 2, 2022

C4 is CAP on your board1 schematics 8)

Bkris.2
Bkris.2Author
Associate III
January 2, 2022

oh ok. C4 size is 0.68uf.

MM..1
Super User
January 2, 2022

Then maybe you need one symbolic schematics with MCU 74595 CD4094

and clean signals info, because in subject you write parallel, but your code have separate signals not parallel.

Your used ICs is serial latched registers, then is controlled with 3 line.

  1. DATA
  2. CLK serial data
  3. LATCH mark data valid and propagate on enabled outputs.

When you say parallel then all your ICs is connected to only 1.2.3.

Make it clean ...