Skip to main content
JT.1
Associate
Feb 17, 2022 5:45 AM UTC
Question

How to set SDA line of I2C low using software

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

This topic has been closed for replies.

2 replies

waclawek.jan
Super User
Feb 17, 2022 7:30 AM UTC

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

JT.1
JT.1Author
Associate
Feb 17, 2022 10:06 AM UTC

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