2021-12-31 11:26 PM
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
2022-01-02 07:29 AM
C4 is CAP on your board1 schematics 8)
2022-01-02 07:54 AM
oh ok. C4 size is 0.68uf.
2022-01-02 08:05 AM
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.
When you say parallel then all your ICs is connected to only 1.2.3.
Make it clean ...
2022-01-02 08:37 AM
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.
2022-01-02 08:51 AM
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 .
2022-01-02 09:10 AM
595 need separate strobe or parallel strobe and orange cascade data or ...
2022-01-02 09:15 AM
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.
PFA the schematic. Please let me know if you need more info.
2022-01-02 09:35 AM
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 ?
2022-01-02 10:05 AM
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);
2022-01-08 03:30 AM
We have changed the hardware design as per your suggestion and it is working as expected. Thanks for your help and support