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-01 12:09 AM
This is possible only in your dreams.
You need separate latch signal or cascade.
2022-01-01 12:35 AM
2022-01-01 12:36 AM
2022-01-01 01:24 AM
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
2022-01-01 04:57 AM
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);
2022-01-01 06:18 AM
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);
2022-01-01 06:55 AM
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).
2022-01-01 07:30 AM
We cant help you , your pinout is mixed and chaos.
Learn how rising edge works...
How size is C4 ?
2022-01-02 05:30 AM
what is C4? do you mean CD 4094