Skip to main content
Visitor II
April 6, 2023
Question

STM8S103 using GPIOB4 as normal GPIO

  • April 6, 2023
  • 2 replies
  • 1519 views

Hi all.

I tried to use GPIOB4 as output but failed.

But it works as I2C ​SCL so I guess the chip ok.

I cant find alternate function for it.

Someone please help me.​

    This topic has been closed for replies.

    2 replies

    Visitor II
    April 6, 2023

    How do you know it failed?

    Post the code used to configure and write output value of GPIO.

    DSmit.5Author
    Visitor II
    April 7, 2023

    GPIO_DeInit(GPIOB):

    GPIO_Init(GPIOB, GPIO_PIN_4, GPIO_MODE_OUT_PP_HIGH_SLOW);

    GPIO_WriteHigh(GPIOB, GPIO_PIN_4);

    It only can pull low not pull up.

    ​The same as GPIOB 5.

    Might be both only OD not PP?​

    Visitor II
    April 7, 2023

    The problem is what I expected. I2C pins are true open-drain pins, see datasheet. This means they can't drive level '1'. Also they don't have internal pull-up resistor. Use them to drive level '0' or try with an external pull-up resistor.

    DSmit.5Author
    Visitor II
    April 7, 2023

    Thank you.

    STM8 much frustating than STM32 and other 8bit micros.

    Dont know why ST made them complicated

    Visitor II
    April 7, 2023

    I don't agree with you. You are complicating. You have to read datasheet and manual. Also the fact that can only drive level '0, usually is not a problem.

    STM8 is a powerful 8bit MCU.

    Do you already worked with any STM32 MCU?

    And the RISC instruction set of CM0+ MCUs!

    Also aligned access to memory!