0
\$\begingroup\$

I'm trying to make a keypad for STM32 MCU using a 74HC14D.653 for debouncing. Datasheet says that it can be fed with 3.3V Vcc so I will not have to make level-shifting between it and MCU. The schematic

The circuit (in theory) outputs logic LOW when buttons are released and logic HIGH when they're pressed.

When I already ordered the PCB and assembled it (I know it's (a bit) stupid not to test this particular circuit before putting it all together...) I found out a pretty unpleasant thing: when for example SW3 is pressed the output on pin 2 is not 3.3V at all. It's only 0.90V!

At the same time the rotary encoder connected to another 74HC14 in the same way works somehow but the built-in switch also does not work (my guess it's just a capacitor discharge when the shaft is being rotated and MCU catches this noise as a valid signal).

What I did wrong and how can I fix it (if it's still possible)?

\$\endgroup\$
  • 3
    \$\begingroup\$ Use a meter to verify that you have 3.3V at pin 14. Disconnect the output of the 74HC14 from any load and check the output voltage. If driving a microcontroller pin, make sure that pin is configured as a input. Verify that the 74HC14 output pin is not shorted to ground somewhere. \$\endgroup\$ – Elliot Alderson Jan 21 at 0:44
  • 1
    \$\begingroup\$ Looks like the uC inputs are active low outputs or something may have been wounded with ESD or ? \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Jan 21 at 1:08
  • \$\begingroup\$ @Elliot Alderson: Voltage at pin 14 is 3.26V. There no shorts in PCB (checked with DRC check during the design in KiCAD and twice manually today...). Cannot disconnect the IC because it soldered to PCB. And speaking about its outputs: the outputs of 74HC14 are connected to PCF8574A as I2C front-end of MCU so maybe the problem is there? \$\endgroup\$ – X16 Jan 21 at 1:29
  • \$\begingroup\$ Here's more detailed circuit: Schematic \$\endgroup\$ – X16 Jan 21 at 1:40
  • \$\begingroup\$ @X16 - make sure you have programmed the PCF8574A correctly - it looks like it is driving the signal low so the two outputs are fighting and you end up with an in-between voltage. \$\endgroup\$ – Kevin White Jan 21 at 1:56
0
\$\begingroup\$

So here's the solution (which looks more like "How-To" for other electronics newbies like me):

  1. Program your IO expander (PCF8574AT in my case) to have all the pins that used for buttons/encoders as INPUTS by writing logic 1's to them:

    uint8_t* buffer;
    buffer = malloc(1 * sizeof(uint8_t));
    *(buffer + 0) = 0b11111111; // all pins are INPUTS
    HAL_I2C_Master_Transmit(&hi2c1, 0x38 << 1, buffer, 1, 200);
    

    where hi2c1 is your I2C port for PCF8574, 0x38 is a PCF's address (pay attention that it must be shifted 1 bit left — see the "<< 1") and buffer is a pointer to data that we want to send to PCF8574. If pins are not set up then you may experience the strange voltage dropdowns on Schmitt trigger outputs down to 0.87-0.90V and PCF will not react to these signals at all (sorry for not describing the phisics of this process here as I still don't understand this yet...);

  2. Reset the interrupt pin by simply reading the data from PCF8574. This operation must be done after the every interrupt that your STM32 responds to:

    *(buffer + 0) = 0;
    HAL_I2C_Master_Receive(&hi2c1, 0x38 << 1, buffer, 1, 200);
    

(Sorry for my bad C and my English and correct me if/where I'm wrong...)


Oh, and here's full keypad schematic for those who want to use this in their projects: Keypad and encoder with Schmitt trigger-based debounce and I2C port expander

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.