I am testing Ganssles debounce circuit (as described here) for a T4. The circuit looks like this:
Vcc is sourced from T4 3,3V pin.
R1, R2 = 100K (I chose high R values to make debouncing times more obvious as a first test)
C = 1uF
Diode = 1N4148
The only deviation from the schematic is that I've omitted the schmitt trigger, based on the assumption that the T4 has onboard schmitt triggers.
My problem is that when I look at the Serial.print():ed switch states, the circuit doesn't appear to reduce bouncing at all. I have looked over the physical circuit several times, and I can't detect any errors in the wirings.
However, looking at the Serial.print() output the logic levels are inverted, which they - to my understanding - shouldn't be with an inverting schmitt trigger operating in the circuit. Am I right in assuming that if a schmitt trigger had been operating as expected, the button states shouldn't be inverted?
Looking at 12.3.1.1 in the i.MX RT1060 Processor Reference Manual it says that one of the input driver characteristics are selectable schmitt trigger or CMOS input mode. Does this mean that the errors are caused because of a disabled schmitt trigger, and if so, how do I enable it?
Are there any other errors/theories that can explain my problem?
Vcc is sourced from T4 3,3V pin.
R1, R2 = 100K (I chose high R values to make debouncing times more obvious as a first test)
C = 1uF
Diode = 1N4148
The only deviation from the schematic is that I've omitted the schmitt trigger, based on the assumption that the T4 has onboard schmitt triggers.
Code:
#include <Arduino.h>
constexpr uint8_t ledPin = 13;
constexpr uint8_t switchPin = 11;
void setup() {
Serial.begin(115200);
pinMode(switchPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
static bool previousSwitchState{};
bool switchState = digitalRead(switchPin);
if (switchState != previousSwitchState) {
Serial.print(String(switchState));
digitalWrite(ledPin, !switchState); // Active low
previousSwitchState = switchState;
}
}
My problem is that when I look at the Serial.print():ed switch states, the circuit doesn't appear to reduce bouncing at all. I have looked over the physical circuit several times, and I can't detect any errors in the wirings.
However, looking at the Serial.print() output the logic levels are inverted, which they - to my understanding - shouldn't be with an inverting schmitt trigger operating in the circuit. Am I right in assuming that if a schmitt trigger had been operating as expected, the button states shouldn't be inverted?
Looking at 12.3.1.1 in the i.MX RT1060 Processor Reference Manual it says that one of the input driver characteristics are selectable schmitt trigger or CMOS input mode. Does this mean that the errors are caused because of a disabled schmitt trigger, and if so, how do I enable it?
Are there any other errors/theories that can explain my problem?