cancel
Showing results for 
Search instead for 
Did you mean: 

How to set SDA line of I2C low using software

JT.1
Associate II

I'm using LC709203F to measure RSOC. It is going to sleep mode after 1.2 Ms.

To wake up from sleep mode , I have write 0x0001 to register 0x15 in fuel gauge.

Prior to that , I have to set SDA line to low for particular time.

Please help me to set SDA line of I2C low for particular time either using HAL or register

2 REPLIES 2

Which STM32?

Just set SDA's pin GPIO_MODER field from AF to Out (from 0b10 to 0b01) and do whatever you need through its GPIO_BSRR (->ODR); when finished, change GPIO_MODER back to AF.

 #define AND &
 #define OR |
 
#define GPIO_Mode_In                        0x00 // GPIO Input Mode
#define GPIO_Mode_Out                       0x01 // GPIO Output Mode
#define GPIO_Mode_AF                        0x02 // GPIO Alternate function Mode
#define GPIO_Mode_AlternateFunction         GPIO_Mode_AF
#define GPIO_Mode_Analog                    0x03 // GPIO Analog Mode
 
   GPIOB->MODER = (GPIOB->MODER AND ~(0
     OR GPIO_MODER_MODER6
     OR GPIO_MODER_MODER7
   )) OR (0
     OR (GPIO_Mode_Out * GPIO_MODER_MODER6_0) // SCL
     OR (GPIO_Mode_Out * GPIO_MODER_MODER7_0) // SDA
   );

JW

Hello JW

Thanks for your response.

I'm using STM32L452. I have attached the image which instructed by LC709203F(Fuel gauge that I'm using) for your reference.

0693W00000JQAWeQAP.png