Skip to content

LTC6810 - 7th Cell is not addressable #60

@DerZwergGimli

Description

@DerZwergGimli

FILE: "LTC6810.cpp"

Seventh Cell or in this case CELL 0 is not addressable see the function.
If you pass in the "int Cell" with "0" the condition "else if (Cell ==0)" will never been called.

/* Helper function to set discharge bit in CFG register */
void LTC6810_set_discharge(int Cell, //The cell to be discharged
						   uint8_t total_ic, //Number of ICs in the daisy chain 
						   cell_asic *ic //A two dimensional array that will store the data
						   )
{
	for (int i=0; i<total_ic; i++)
	{
		if (Cell<7)
		{
		  ic[i].config.tx_data[4] = ic[i].config.tx_data[4] | (1<<(Cell-1));
		}
		else if (Cell ==0)
		{
		Serial.println("Hello");
		  ic[i].config.tx_data[4] = ic[i].config.tx_data[4] | (0x80);
		}
	}
}

may change to...

/* Helper function to set discharge bit in CFG register */
void LTC6810_set_discharge(int Cell,		 //The cell to be discharged
						   uint8_t total_ic, //Number of ICs in the daisy chain
						   cell_asic *ic	 //A two dimensional array that will store the data
)
{
	for (int i = 0; i < total_ic; i++)
	{
		if (Cell < 7 && Cell != 0)
		{
			ic[i].config.tx_data[4] = ic[i].config.tx_data[4] | (1 << (Cell - 1));
		}
		else if (Cell == 0)
		{
			ic[i].config.tx_data[4] = ic[i].config.tx_data[4] | (0x80);
		}
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions