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

C4 is CAP on your board1 schematics 😎

Bkris.2
Associate II

oh ok. C4 size is 0.68uf.

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 ...

Bkris.2
Associate II

Sorry, I would have confused you saying that 595 connected are in parallel. But they are neither connected in parallel nor serial (cascaded) and connected through bus lines (Data, clock, latch). As you have mentioned all the ICs are connected with 1.2.3. My program would be wrong. So I am trying to get some help to code in correct way. Please help me if you are able to understand the hardware and guide me.

For example on your schematics is 595 pin 12 (signal 3) not connected to MCU

in your code seems signal 2 for CD4094 is GPIOPIN0 but same signal 2 for 595 is GPIOPIN12

and chaos continue GPIOPIN1 and 11 seems be output enable separate usw...

Im lost in your signal connection .

MM..1
Chief II

0693W00000HqKwbQAF.png595 need separate strobe or parallel strobe and orange cascade data or ...

Bkris.2
Associate II

For 595, Pin 12 (Clock i.e., RCLK+SRCLK) connected to MCU via buffer (74hc244n).

For 595, Pin 1 (OE) connected to MCU via buffer (74hc244n).

595 is receiving clock, OE and data (from CD 4094) is receiving via bus lines.

For CD4094, Pin 0 (clock), Pin 11 (OE), Pin 2 (Data), Pin 10 (Strobe).

There are 2 clock signals, one for 595 and another for CD4094 and same for OE as well.

0693W00000HqKxFQAV.jpgPFA the schematic. Please let me know if you need more info.

MM..1
Chief II

For 595, Pin 12 (Clock i.e., RCLK+SRCLK) this is primary fail, you 595 never write clean data because you connect serial clock and register latch write together. Ok you use delay with R 39k and C 0,68uF ,but this isnt clean use. Too you alltime set outputs to tristate with OE. This is used only ...

BUT ok i read your schematics better and now understand CL1-8 is same circuits with 595 usw.

Every bit on CD out is one data input to CLx , then code need change ...

BUT now seems you need write 8x 8 bits and not only 16 bits ?

MM..1
Chief II

Try this

uint8_t test[] = {1,2,4,8,16,32,64,128};   // CL1-8 ábit data
 
 //set all gpio to high speed
 
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11, GPIO_PIN_RESET); // CD4094 OE
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET); // 74hc595 OE
//in normal use OE is enabled alltime you can change later
 
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET);  //CD4094 STROBE
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); // 595 CLOCK
//go low prepare for data
HAL_Delay(300);
 
for (int bit=0; bit<8; bit++)   {
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET);  //CD4094 STROBE
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); // 595 CLOCK
 
for (int i=0; i <8; i++) { //MSB first CL8 first        
 
   output = test[7-i] & (1<<(7-bit));
   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_Delay(1);
 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET); // CLOCK
}
  
HAL_Delay(300);

Bkris.2
Associate II

We have changed the hardware design as per your suggestion and it is working as expected. Thanks for your help and support