Skip to main content
Visitor II
August 31, 2022
Question

Read multiple digital inputs at once

  • August 31, 2022
  • 2 replies
  • 1040 views

I am new to STM MCU and have started working with stm8s105k4. I have a 4 bit digital input and wants to know how can I read that 4 bit at once which is connected to PORTC.

Below logic is very lengthy and not a good way to read inputs. Kindly help.

if ((!GPIO_ReadInputPin(GPIOC, GPIO_PIN_3)) && (GPIO_ReadInputPin(GPIOC, GPIO_PIN_4)) && (GPIO_ReadInputPin(GPIOC, GPIO_PIN_5)) && (!GPIO_ReadInputPin(GPIOC, GPIO_PIN_6)))

    This topic has been closed for replies.

    2 replies

    Graduate II
    August 31, 2022

    uint16_t foo = GPIOC->IDR;​

    Graduate II
    August 31, 2022

    You should take a look at this app note.

    It explains all the GPIO's registers and their use. (Including GPIOx_IDR)