Skip to main content
DSmit.5
Associate II
Question

STM8S103 using GPIOB4 as normal GPIO

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.

    5 replies

    AA1
    Senior III

    How do you know it failed?

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

    DSmit.5
    DSmit.5Author
    Associate II

    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?​

    AA1
    Senior III

    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.5
    DSmit.5Author
    Associate II

    Thank you.

    STM8 much frustating than STM32 and other 8bit micros.

    Dont know why ST made them complicated

    AA1
    Senior III

    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!