-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 11/26/2012 08:56 AM, Peter Ross wrote:
> Hi,
>
> Simavr appears to be inadvertently setting ioport PIN values when a
> PORT write is requested. This was observed while attempting to run
> software that uses the same ioport for reading and writing.
>
> The emulation environment is simple:
>
> // initialise atmega644 mcu, load program, set port B0 to 1
> avr_raise_irq(avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('B'), 0),
> 1); // run sim
>
> The avr c program:
>
> main(){ DDRB = 0; PORTB = 0; for(timer = 0; timer < 1000;
> timer++); value = PINB & 0x1; ... printf("value: %i\n", value);
>
> Result: The program in simavr prints out 0, when on real hardware
> it prints 1.
I suppose that example program is simulating an environment in which
some external component is pulling up PB0?
I ran into the same issue a while back (it's covered in section 6.8
and 7 of my thesis [1]), and I don't think there's a decent way to
solve this without making simavr aware of the connected component, the
state of that component, and a resolution function for PIN values
which combines it with the internal state (input/output, pull-up or not).
Michel did not seem to be enthusiastic about that though ;)
I ended up using a hackish workaround for my purposes.
Jakob
[1]
https://github.com/schuay/bachelors_thesis
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with undefined -
http://www.enigmail.net/
iQEcBAEBAgAGBQJQtyNlAAoJEEVsepuRuEKu3joH+gI3Iu6Qx189jO4N1DxGzd0E
amzU3MKbovrWRU5YEUOTmX8mbNlgjkBT5RsDVzJIQh2rWJPdV8pQV7nDyrtONQWh
kQtjfggkZQg7R/byqXq+MEt0IOxOEeZtPgvauyxN/b26vFP5ghW3VumdUSlv7LZf
03BfaAEUVEXGa13DqW8kvQ9aAgT9C6/JkXKT0qCtGZ6Rz7rjqS6jKr2Pzm69oCE4
2eSNExH6JMPSmAzVSOTjIDPdbYnjMAP/omYKPrMLL91G1OjLbNqlKltGGplJEGzs
5d7oYI+h4bEQ0bFX4YmZLSJI6nuW/d/SM9sDLO2UkkwF6Hq+OEYm2cP/igCBAe4=
=FHWg
-----END PGP SIGNATURE-----