# Is there any reason some pins don't not work as GPIO on ATmega?

I got an ATmega8515 and this simple code inside main():

void main(void) {
DDRD = 0xFF;
PORTD = 0xFF;

while(1){}
}


I expect to see all the pins high, but PD5-PD7 are still in hi-Z state. No alternative function is configured - these are the first lines of the function! Any ideas please? Is it a compiler bug?

Have tried this on two MCUs bought from different suppliers, not likely for both to be defective.

P.S. I use cross-avr-gcc 5.4.0-1.14 under openSUSE 42.3

P.P.S. Once in awhile I faced something similar, playing with optimization (-O) flags helped. Does not do now.

• How do you know/what makes you think they are in tri-state mode? (I assume that's what you mean.) – DiBosco Oct 2 '17 at 13:00
• Also, what happens when you set a break point just after the PORTD = 0xFF; line? How do the pins look then? – DiBosco Oct 2 '17 at 13:03
• The pin looks like low on oscilloscope, but when I try to load it with a LED through 1K resistor (another side goes to power bus) it goes high. Other pins of the port works fine with LED. – Ilia Nedoluzhko Oct 2 '17 at 23:02
• Have you tried on more than one chip? – Tom Carpenter Oct 3 '17 at 21:40
• Have you decompiled the code to see if it matches expectations? – Ignacio Vazquez-Abrams Oct 3 '17 at 22:21