0

I will use L476RG to connect with a battery power board, battery board will use two Gpio ports to ONLY send out info, such as battery is full, battery is in charge, and so on, now the question is, in STM32CubeMX, shall I set those two Gpio ports as input or output status? Also in Hal function HAL_GPIO_ReadPin(..), what is value I could get? in battery manual I should read blinking 2.5Hz and 0.5 Hz, high and low 4 status. Thanks

adam
  • 49
  • 6
  • 2
    you can set the pins any way you like ... we have no idea how you are connecting anything, so we cannot make any other comments – jsotola Jun 24 '19 at 19:41
  • or the first question could be when we need to use gpio_input, when we need to use gpio_output? tks – adam Jun 24 '19 at 21:57

1 Answers1

1

Inputs and outputs always imply from the point of view of the MCU.

Set the pin to input if the signal is generated by the other component.

Set the pin to output if the signal is to be generated by the MCU.

Read carefully the General-purpose I/Os (GPIO) chapter in the reference manual, and also these posts before setting input/output modes if you don't want to damage components.

Push-pull/open drain; pull-up/pull-down

STM32 Understanding GPIO Settings