AnsweredAssumed Answered

How can I set pb8 to SDA on stm32f103rc?

Question asked by Youngmin Choi on Apr 19, 2018
Latest reply on Apr 19, 2018 by waclawek.jan

I want I2C function on stm32f103rct.

pb8-> sda and pb9-> scl

 

I set ports configuration  like this

#define I2C_SCL_HIGH    GPIOB->BSRR = 0x00000200    //PB9 0x00000200 set PB9 to 1
#define I2C_SCL_LOW     GPIOB->BRR = 0x00000200 // reset PB9
#define I2C_SDA_HIGH    GPIOB->BSRR = 0x00000100 //PB8 0x00000100 set PB8 to 1
#define I2C_SDA_LOW     GPIOB->BRR = 0x00000100 // reset PB8
#define I2C_SDA_INPUT   (GPIOB->IDR & 0x00000100) // get PB8 is bit
#define I2C_SDA_INPUT_MODE  GPIOB->CRH &= 0x0fffffff; GPIOB->CRH |= 0x00000008 //PB8 set input push-pull-up
#define I2C_SDA_OUTPUT_MODE GPIOB->CRH &= 0x0fffffff; GPIOB->CRH |= 0x00000003 //PB8 output mode max speed 50Mhz */
but pb8 input is always 0.
Is there any consideration on this setting?

Outcomes