cancel
Showing results for 
Search instead for 
Did you mean: 

STC3115: Does not start up

Posted on September 28, 2016 at 19:51

Hello,

We are using a STC3115 in one of our designs. The problem is that it does not start up.

I read: 

https://github.com/st-sw/STC3115GenericDriver/wiki/STC3115-FAQ

It looks like the problem is that the BATD is 'high'. I tried to force it low by connecting it to ground through a 1K resistor. However, the output of BATD is still 3.7V. Is there a way I can force it to become 'low'?

On the software side:

- I can communicate via I2C. The counter value reads: 1. So it seems that it starts, but then stops.

- A soft reset does not help

- I call BatterMonitorInit once 

BatteryReadStateOfCharge is called every 500 ms.

- This results in the following o

utput:

My question is, why does it not start? Is 

there something else i need to initialise?

Code 

void BatteryMonitorInit(TI2CWriteReadFunction I2CWriteReadFunction)

{

    I2CWriteRead = I2CWriteReadFunction;

    TxBuffer[0] = 1; //regctrl

    TxBuffer[1] = 0; //reset

    I2CWriteRead(TxBuffer, 2, RxBuffer, 0);

    // nrf_delay_ms(10);

    //write REG_CC_CNF

    TxBuffer[0] = REG_CC_CNF;

    TxBuffer[1] = 210; //466

    TxBuffer[2] = 1;

    I2CWriteRead(TxBuffer, 3, RxBuffer, 0);

    //write REG_VM_CNF

    TxBuffer[0] = REG_VM_CNF;

    TxBuffer[1] = 157; //157

    TxBuffer[2] = 0;

    I2CWriteRead(TxBuffer, 3, RxBuffer, 0);    

    TxBuffer[0] = REG_MODE;

    TxBuffer[1] = 1+16;

    I2CWriteRead(TxBuffer, 2, RxBuffer, 0);

}

uint8_t BatteryMonitorReadStateOfCharge(void)

{

    TxBuffer[0] = REG_SOC;

    I2CWriteRead(TxBuffer, 1, RxBuffer, 2);

    uint16_t StateOfCharge = (RxBuffer[1] << 8) + RxBuffer[0];

    dbg(''rx[1]:%d\n'',RxBuffer[1]);

    dbg(''rx[0]:%d\n'',RxBuffer[0]);

    uint8_t StateOfChargePercentage = StateOfCharge >> 9;

    TxBuffer[0] = 1; //regctrl

    I2CWriteRead(TxBuffer, 1, RxBuffer, 1);

    dbg(''REG_CTRL\n'')

    dbg(''rx[0]:%d\n'',RxBuffer[0]);

    TxBuffer[0] = 0; //regmode

    I2CWriteRead(TxBuffer, 1, RxBuffer, 1);

    dbg(''REG_MODE\n'')

    dbg(''rx[0]:%d\n'',RxBuffer[0]);

    TxBuffer[0] = 4;

    I2CWriteRead(TxBuffer, 1, RxBuffer, 2);

    dbg(''Counter\n'');

    dbg(''rx[0]:%d\n'',RxBuffer[0]);

    dbg(''rx[1]:%d\n'',RxBuffer[1]);

    TxBuffer[0] = 8; //reg voltage

    I2CWriteRead(TxBuffer, 1, RxBuffer, 2);

    dbg(''batt voltage\n'');

    dbg(''rx[1]:%d\n'',RxBuffer[1]);

    dbg(''rx[0]:%d\n'',RxBuffer[0]);

    TxBuffer[0] = 13; //reg open circuit voltage

    I2CWriteRead(TxBuffer, 1, RxBuffer, 2);

    dbg(''Open circuit voltage\n'');

    dbg(''rx[1]:%d\n'',RxBuffer[1]);

    dbg(''rx[0]:%d\n'',RxBuffer[0]);

    TxBuffer[0] = 22; //reg relax

    I2CWriteRead(TxBuffer, 1, RxBuffer, 1);

    dbg(''relax counter\n'');

    dbg(''rx[0]:%d\n'',RxBuffer[0]);

    return StateOfChargePercentage;

}

Resulting Output:

SOC

rx[1]:58

rx[0]:168

REG_CTRL

rx[0]:4

REG_MODE

rx[0]:17

Counter

rx[0]:1

rx[1]:0

batt voltage

rx[1]:6

rx[0]:173

Open circuit voltage

rx[1]:26

rx[0]:180

relax counter

rx[0]:120

result 29

SOC

rx[1]:58

rx[0]:160

REG_CTRL

rx[0]:4

REG_MODE

rx[0]:17

Counter

rx[0]:2

rx[1]:0

batt voltage

rx[1]:6

rx[0]:162

Open circuit voltage

rx[1]:26

rx[0]:179

relax counter

rx[0]:120

#stc3115-issue-startup
3 REPLIES 3
veli-matti
Associate II
Posted on September 29, 2016 at 18:17

Hi

I'm struggling with a problem that might be related. In my HW the BATD pin is pulled high. That's incorrect, I know. But the symptoms are that there are problems with I2C write operations. Registers are read correctly, e.g. the device ID, but when running the driver downloaded from the manufacturer's site, register writes to REG_ALARM_VOLTAGE and REG_RAM0 fail. STM32F4 HAL reports HAL_I2C_ERROR_AF, which apparently means that STC3115 does not ack the write.

Are you able to write into those registers?

Gregory Go.
Senior II
Posted on December 08, 2017 at 01:59

Hello,

As long a the BATD pin is not pulled-down, the STC3115 will not start the battery monitoring because it detects that no battery is connected.

You can read the 'BATFAIL' bit in register REG_CTRL (@ADDRESS 1) to verify that the issue is due to battery detection.

If BATFAIL == 1, it means the STC3115 has detected an error.

Best regards.

Posted on December 08, 2017 at 02:09

Hi,

If you can read STC3115 registers, it means the I2C write sequence should work, because an I2C random Read sequence always start with a Write.

So it seems the issue is coming from your Write implementation on the STM32 side.

The STC3115 Slave address is 8-bit (7-bit address, with a R/W bit at the end). It is not a 10-bit address like some EEPROM memories. So check the STM32  I2C master interface is not configured for 10-bit devices.

Also, when you perform a I2C Write, check that the R/W bit is set to 0.