1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ How do you know/what makes you think they are in tri-state mode? (I assume that's what you mean.) \$\endgroup\$ – DiBosco Oct 2 '17 at 13:00
  • \$\begingroup\$ Also, what happens when you set a break point just after the PORTD = 0xFF; line? How do the pins look then? \$\endgroup\$ – DiBosco Oct 2 '17 at 13:03
  • \$\begingroup\$ 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. \$\endgroup\$ – Ilia Nedoluzhko Oct 2 '17 at 23:02
  • 1
    \$\begingroup\$ Have you tried on more than one chip? \$\endgroup\$ – Tom Carpenter Oct 3 '17 at 21:40
  • 2
    \$\begingroup\$ Have you decompiled the code to see if it matches expectations? \$\endgroup\$ – Ignacio Vazquez-Abrams Oct 3 '17 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.