cancel
Showing results for 
Search instead for 
Did you mean: 

STM8S103F3 PB5/SDA behaves incorrect when used as GPIO

e_zhui2
Associate II
Posted on May 03, 2010 at 11:25

STM8S103F3 PB5/SDA behaves incorrect when used as GPIO

4 REPLIES 4
mozra272
Associate II
Posted on May 17, 2011 at 15:08

Hi Dennis,

The I2C pins are configured as true open-drain I/O internally, (P-buffer and protection diode to VDD are not implemented) so is not possible to use them as output pins

can you please check with external pull-up 4.7k on these I/O.

Regards

mozra

e_zhui2
Associate II
Posted on May 17, 2011 at 15:08

Thanks, Mozra.

I am not using the I2C pin to drive 74AC164M now, but with other normal GPIOs. Everything is all right.

But I am still using the I2C pins(GPIO mode) to drive other components, currently they work ok. Concerning to your reply ''The I2C pins are configured as true open-drain I/O internally, (P-buffer and protection diode to VDD are not implemented)

so is not possible to use them as output pins

'', I don't know if I am right, is there any underlying risk to use I2C pins as output?

Thanks and Regards

jeffrey23
Associate II
Posted on May 17, 2011 at 15:08

Hi Dennis,

May I use STM8S103F3 PD5/PD6 as I2C SCL/SDA pins (bit-banging approach) ?

Does it mean that I need to switch their configuration according to I2C

Read/Write modes ?

    // Setup Port D

    /*

    [2]101

           7 6 5 4 3 2 1 0

           | | | | | | | |

           | | |___________ SCL (Output)     Push pull output

           | |_____________ SDA (I/O   )     Push pull output

    DDR    0 1 1 0 0 0 0 0

    CR1    0 1 1 0 0 0 0 0

    CR2    0 0 0 0 0 0 0 0

    */

    GPIOD->DDR = 0x70;

    GPIOD->CR1 = 0x70;

    GPIOD->CR2 = 0x00;

 Does the STM8S103F3 support 8051 MCU quasi-bidirection mode ?

jeffrey23
Associate II
Posted on May 17, 2011 at 15:08

Dennis,

Do you mean that STM8S103F3 PB.4/PB.5 can be used

as normal Open Drain pins ? Could you tell me how to configure their regisers ?

    // Init Port B

    /*

    [2]101

           7 6 5 4 3 2 1 0

           | | | | | | | |

           | | | |_________ I2C SCL (Output)    Open drain output

           | | |___________ I2C SDA (Output)    Open drain output

    DDR    0 0 1 1 0 0 0 0

    CR1    0 0 0 0 0 0 0 0

    CR2    0 0 0 0 0 0 0 0

    */

    GPIOB->DDR = 0x30;

    GPIOB->CR1 = 0x00;

    GPIOB->CR2 = 0x00;

Are they  correct ? What did I miss else ?