Close

MCU Weirdness

A project log for ESP32 Bluetooth Gamepad

A bluetooth Gamepad with an analog joystick

tyrigityrigi 02/19/2021 at 19:100 Comments

With the V4 board and the resulting GPIO scramble to accommodate an SD card, I started having an issue. The top two rows were behaving weirdly. On boot, the keypad would report all keys in the top two rows pressed. When I actually pressed a key in that row, all other keys in the row would be recognized as released. When I released the pressed key, the keypad would report the key as being released, wait a small increment, then show the whole row as pressed again. I did some digging in the ESP datasheet, and turns out the pins I'm using for those rows are also used for mode selection during boot.

Long story short: those two pins have internal hardware that causes a positive charge to accumulate on row 0's pin, and a negative charge to accumulate on row 1's pin. It's weak enough to take a few tens of ms to sway the digital state of the pin, but strong enough to persist through multiple reads of the pin's digital state. The fix, crude as it is, is to "slap" the pins high and low, then switch back to an input state just before taking a reading. I could probably fix this with a hardware change, but I'm frankly tired of doing board revisions, and I'd have to do some weird stuff to avoid holding the pins in a weird state during boot which would change some options I don't want changed. Like internal flash voltage level.

Discussions