Hi, I am finding side-effects to PIN values that confuse me. I'm avr noob with c/c++ sw background.
Set-up:
atmega328b in arduino body, En-reset clipped.
AS7 attached to ICE attached to Arduino ISP
using DebugWire
I am trying to get PORTB and PORTD into a zero'd out state at application init. I'd like DDRx, PORTx, and PINx to be all 0'd.
I have an InitPorts function, called first thing from main().
On function entry, AS7 debugging shows the following, Note that PINB is not entirely 0'd
So, I try to do the following:
1) DDRB = 0xFF; // enable output on all pins, and also set all values on PORTB to 0
result:
-- cool, does what I expected, also clears PINB. But bc I want to start with pins config'd for Input by default, I do...
2) DDRB = 0;
result:
-- not what i expected. cleared direction, yeah, but now some Pins are non-zero.
As noted, I'm noobing. Are the pins floating? Is the Debugger reliable? If I really want to have this initial state, do I need external pull down resistors on the pins?
Thanks. O