Skip to main content
Visitor II
June 17, 2020
Solved

How to configure PC0 and PC1 as ordinary pins on STM8L051F3?

  • June 17, 2020
  • 1 reply
  • 874 views

Hello! I am using STM8L051F3 with Stm8 SPL headers. I am trying to configure PC0,PC1,PC4 as output with high level:

CLK->PCKENR1 &= `CLK_PCKENR1_I2C1;
GPIOC->DDR |= (1<<0)|(1<<1)|(1<<4);
GPIOC->CR1 |= (1<<0)|(1<<1)|(1<<4);
GPIOC->ODR |= (1<<0)|(1<<1)|(1<<4);

as a result, i got high level only on PC4.

According to DS1178 Rev4 ( STM8L051f3 datasheet) p.23 PC0 and PC1 has main function as

 PORT and alternate function as I2C. I think, that somehow PC1 and PC0 acts as I2C (SDA/SDL)

 Please help me to configure PC0 and PC1 as ordinary port.

    This topic has been closed for replies.
    Best answer by Cristian Gyorgy

    PC0 & PC1 are true open drain ports, so if you want to measure/read a 1 value on the ports you need pull-ups.

    1 reply

    Visitor II
    June 21, 2020

    PC0 & PC1 are true open drain ports, so if you want to measure/read a 1 value on the ports you need pull-ups.