simavr
simavr copied to clipboard
Internal pull-up algorithm test
This patch provides a test case which demonstrates a problem with implementation of pull-ups in simavr. The firmware configures three pins of port D as internally pulled-up inputs, other three pins of the same port as outputs, then connects push buttons to every input, simulates key presses and translates inputs state to the outputs, one by one. ATTENTION: This test fails on the current simavr version, the solution will be provided later. See issue #204 for details.
I've just ran into this bug head on.
My project uses internal pullups to detect button pushes, but the simulator fails to control any pins where the pullups are enabled.
Do we have a solution for this as of 2022?
Not ideal workaround: (have not tried yet, but will) Poll the AVR core to find input pins with pullups, and disable them in the main loop from simulator code - this makes the changes transparent for the client code.
What behaviour do you see? The example given in #204 is sufficiently complicated that it is not really clear. My guess is that the complaint was about the behaviour that is clear in the code: any write to a port that has a pulled-up input pin will set the pin state to one.
I believe there are two fixes for this: either comment-out the pullup code; or monitor writes to PORTx and assert the wanted state in response. MP suggest the second in a comment on #204. I pushed a commit in my fork that adds the conditional compilation, but left pullups enabled by default. (ef0e7a5cb866ac77aa688f9a3ab3688c7f45e7f6)