SLVAFT2B May 2024 – April 2025 TPS2HCS10-Q1
The current sense code example shows how the HCS family of smart fuse high-side switches has a scalable and extremely flexible current sense. This code example sets up a 1ms time that periodically wakes up and samples the load current of channel 1 of the high-side switch. If the load current is below 500mA, then the device enables the following settings of the high-side switch:
A breakpoint line is set at each event to allow the user to break and understand the behavior of the current sense. When the low current sense mode is entered in the software, a state variable (inLowCurrent) is set to signify the current status and the device continues to periodically sample the current. If the current level saturates the ADC reading, the low current mode is exited and the normal scaling or KSNS modes are used. A snippet of the relevant code are shown in the following code:
while(1)
{
__WFI();
/* Reading the load current value. Read the register twice
as the */
resCode = HCS_readRegister(TPS2HCSXX_ADC_RESULT_CH1_I_REG,
¤tValue);
resCode.byte |= HCS_readRegister(TPS2HCSXX_ADC_RESULT_CH1_I_REG,
¤tValue).byte;
/* For each transaction, the high-side switch returns an error
status code that reports common faults of the device. */
if(resCode.byte != 0)
{
handleError(resCode);
}
/* Masking out the relevant bits */
currentValue &= TPS2HCSXX_ADC_RESULT_CH1_I_ADC_RESULT_CH1_I_MASK;
/* Check to see if the threshold is below where to turn
on current sense scaling and change the KSNS ratio and enable
scaling by 8x. This allows for */
if((currentValue < LOW_CURRENT_SNS_THRESHOLD) &&
(inLowCurrent == false))
{
exportConfig.diagConfigCh1.value.bits.OL_ON_EN_CH1 = 1;
exportConfig.diagConfigCh1.value.bits.ISNS_SCALE_CH1 = 1;
inLowCurrent = true;
HCS_writeRegister(TPS2HCSXX_CH1_CONFIG_REG,
exportConfig.diagConfigCh1.value.word);
/* Adding place to set a breakpoint for the sake of demonstration */
asm ("nop");
}
else if((currentValue == LOW_CURRENT_SNS_SATURATION) &&
(inLowCurrent == true))
{
exportConfig.diagConfigCh1.value.bits.OL_ON_EN_CH1 = 0;
exportConfig.diagConfigCh1.value.bits.ISNS_SCALE_CH1 = 0;
HCS_writeRegister(TPS2HCSXX_CH1_CONFIG_REG,
exportConfig.diagConfigCh1.value.word);
/* Adding place to set a breakpoint for the sake of demonstration */
asm ("nop");
}
}
By being able to detect low current and enable the scaling and KSNS modes, the high-side sense can adapt the current sense resolution and meet applications requiring high current sense accuracy.