I'm trying to use PC14 and PC15 on Nucleo F401RE board, as inputs using this simple code:


  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);

  // initialize ID pins as inputs
  GPIO_InitTypeDef gpio_init_struct;
  gpio_init_struct.GPIO_Mode = GPIO_Mode_IN;
  gpio_init_struct.GPIO_PuPd = GPIO_PuPd_UP;
  gpio_init_struct.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
  GPIO_Init(GPIOC, &gpio_init_struct);

  // read ID pins
  uint8_t inputs_state = 0;
  inputs_state |= GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_13);
  inputs_state |= GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_14) << 1;
  inputs_state |= GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_15) << 2;

Unfortunately, while PC13 works as expected, PC14 and PC15 always stay high in case of pull-up configuration or low in case of pull-down.

The reference on page 155 states:

The LSE oscillator pins OSC32_IN and OSC32_OUT can be used as general-purpose PC14 and PC15 I/Os, respectively, when the LSE oscillator is off. The PC14 and PC15 I/Os are only configured as LSE oscillator pins OSC32_IN and OSC32_OUT when the LSE oscillator is ON. This is done by setting the LSEON bit in the RCC_BDCR register. The LSE has priority over the GPIO function.

So I'm setting LSE off, but still no result. What am I missing?


One of the issue I find is the jumper settings

By default, both jumpers SB48 and SB49 are open.

enter image description here

Reference: Schematics of Nucleo F401RE

Second way is to later measure the resistance from the resistors highlighted and
connector CN7 pin numbers 25 and 27.
enter image description here
If the hardware settings is fine, you should read zero ohms approximately.

| improve this answer | |
  • \$\begingroup\$ Damn, I totally forgot to check Nucleo schematic. Thanks! \$\endgroup\$ – mactro Jun 8 '18 at 17:04

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.