simulavr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Simulavr-devel] [PATCH] use static callbacks instead of template pa


From: Michael Hennebry
Subject: Re: [Simulavr-devel] [PATCH] use static callbacks instead of template param for IOReg
Date: Sat, 1 Jul 2017 12:37:56 -0500 (CDT)
User-agent: Alpine 2.20 (DEB 67 2015-01-07)

On Sat, 1 Jul 2017, panic wrote:

Example: PINx toggle feature

DDRB = 0xff;
PORTB = 0xff;
PINB |= _BV(PB0); // sbi _SFR_IO_REG(PINB), 0

For such things, I recommend against using C code as an example.
What the compiler should do with such things is not obvious.
In the case of avr-gcc,
what it does depends signifcantly on the optimization level.
The choice of sbi or not affects the final outcome, not just the speed.
'Tain't obvious that such statements should even be allowed.

Expected behaviour:
 PB0 toggles from 1 -> 0
PINB is a bit-accessible IO register. The SBI instruction behaves as if
0x01 had been written.

Simulavr behaviour:
 All bits (PB7..PB0) toggle from 1 -> 0.
Simulavr emulates SBI as RMW:
- Read PINB: 0xff (each input stage=1)
- Modify: 0xff | 0x01 --> 0xff
- Write: 0xff --> PINB, == "PORTB ^= 0xff"

The PINx toggle feature can also be used to toggle pullups ("independent
on the value of DDRxn").

--
Michael   address@hidden
"Sorry but your password must contain an uppercase letter, a number,
a haiku, a gang sign, a heiroglyph, and the blood of a virgin."
                                                             --  someeecards



reply via email to

[Prev in Thread] Current Thread [Next in Thread]