Uh, seems that things are not so easy...
This time I guess it is a hardware concern.
I put a pin (c2) high somewhere before the routine that reads the incoming signal and put it low after, just to have a visual estimation of the time it takes to complete the routine.
The pin is just a test pin that lights a 5V led.
If I don't connect the led to the pin, then the signal is invalid but if I connect the led, all incoming signals are good...
C2 is an output pin, default low (no external WPU or WPD resistor).
If I connect the pin to GND through a 10K resistor, it is better but sometimes the signal is missed. Connecting the led ensures the signal is collected fine...
It makes no sense.
1 hour later:
I noticed I left from previous test C0 as input, default high but not using an external WPU.
I changed it back to output, default low.
Still I would miss some signals.
Then adding a 10K WPD instead of a led on the OUTPUT pin C2 seems to fix the problem.
I wonder how a WPD on an OUTPUT pin acts on my code ???
Bookmarks