cancel
Showing results for 
Search instead for 
Did you mean: 

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

Bkris.2
Associate II

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

19 REPLIES 19
MM..1
Chief III

This is possible only in your dreams.

You need separate latch signal or cascade.

Bkris.2
Associate II

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
Associate II
 
MM..1
Chief III

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
Associate II

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
Chief III

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
Associate II

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
Chief III

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

Learn how rising edge works...

How size is C4 ?

Bkris.2
Associate II

what is C4? do you mean CD 4094