From d27b162400db056b69f50869d3c070846dbccfef Mon Sep 17 00:00:00 2001 From: Ben Blazak Date: Sun, 3 Jun 2012 21:12:15 -0700 Subject: [PATCH] bugfix: add delay between teensy col write and pin read without this we have ghosting problems on the bottommost keys of the teensy side thanks to hasu (on geekhack) for the suggestion, and PrinsValium for confirming erratic behavior with his firmware without these delays. thanks DOX for making the changes and trying it out. i'm just adding it to the repo. --- src/keyboard/ergodox/teensy-2-0.c | 6 ++++-- src/keyboard/ergodox/teensy-2-0.md | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/keyboard/ergodox/teensy-2-0.c b/src/keyboard/ergodox/teensy-2-0.c index 82096df..d88f44f 100644 --- a/src/keyboard/ergodox/teensy-2-0.c +++ b/src/keyboard/ergodox/teensy-2-0.c @@ -39,8 +39,10 @@ * "teensy-2-0.md", and the '.svg' circuit diagram. */ // --- helpers -#define teensypin_write(register, operation, pin) \ - _teensypin_write(register, operation, pin) +#define teensypin_write(register, operation, pin) do { \ + _teensypin_write(register, operation, pin); \ + _delay_us(1); /* allow pins time to stabalize */ \ + } while(0) #define _teensypin_write(register, operation, pin_letter, pin_number) \ ((register##pin_letter) operation (1<<(pin_number))) diff --git a/src/keyboard/ergodox/teensy-2-0.md b/src/keyboard/ergodox/teensy-2-0.md index e1edf5b..180f147 100644 --- a/src/keyboard/ergodox/teensy-2-0.md +++ b/src/keyboard/ergodox/teensy-2-0.md @@ -78,6 +78,22 @@ * Switching the row pins between hi-Z and drive low (treating them as if they were open drain) seems just as good as, and a little safer than, driving them high when the row's not active. + * We need to delay for at least 1 μs between changing the column pins and + reading the row pins. I would assume this is to allow the pins time to + stabalize. + * Thanks to [hasu] (http://geekhack.org/member.php?3412-hasu) + for the suggestion [here] + (http://geekhack.org/showthread.php?22780-Interest-Check-Custom-split-ergo-keyboard&p=606415&viewfull=1#post606415), + and [PrinsValium] (http://geekhack.org/member.php?6408-PrinsValium) + for noting that his firmware had erratic behavior without the delays + [here] + (http://geekhack.org/showthread.php?22780-Interest-Check-Custom-split-ergo-keyboard&p=606426&viewfull=1#post606426). + DOX tried it and confirmed that it worked for his protoype PCB (as of + 3 June 2012) [here] + (http://geekhack.org/showthread.php?22780-Interest-Check-Custom-split-ergo-keyboard&p=606865&viewfull=1#post606865). + Before adding a delay we were having [strange problems with ghosting] + (http://geekhack.org/showthread.php?22780-Interest-Check-Custom-split-ergo-keyboard&p=605857&viewfull=1#post605857). + ### PWM on ports OC1(A|B|C) (see datasheet section 14.10)