0
\$\begingroup\$

Why does enabling the clock for port C set the IDR bit 1? It's the configuration for a Nucleo-F767ZI.

enter image description here

\$\endgroup\$
1
\$\begingroup\$

The default mode of the pin is as an input, as soon as you enable the peripherals clock (well, a few clock cycles later), the pins state is clocked into the IDR.

Something is making that pin high.

As a comment on your code, there are defines for the bit positions in the registers, probably provided in the same include as you're getting the RCC pointer from, RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN; is more readable than RCC->AHB1ENR |= 4;

\$\endgroup\$
1
\$\begingroup\$

The pin is connected to something that makes the pin voltage to be high enough for the pin to read as logic 1, but state cannot be read until peripheral clock is enabled so it will read logic 1 only after enabling the clock.

\$\endgroup\$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.