SLVAFT2B May   2024  – April 2025 TPS2HCS10-Q1

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1Software Ecosystem
  5. 2Platform Drivers
    1. 2.1 Driver Concept
    2. 2.2 Supported Platforms
    3. 2.3 Porting to Other Platforms
    4. 2.4 API Guide
      1. 2.4.1  tHCSResponseCode Union Reference
      2. 2.4.2  float_t HCS_convertCurrent (uint16_t rawValue, uint16_t ksnsVal, uint16_t snsRes)
      3. 2.4.3  float_t HCS_convertTemperature (uint16_t rawValue)
      4. 2.4.4  float_t HCS_convertVoltage (uint16_t rawValue)
      5. 2.4.5  tHCSResponseCode HCS_getChannelFaultStatus (uint8_t chanNum, uint16_t * fltStatus)
      6. 2.4.6  tHCSResponseCode HCS_getDeviceFaultSatus (uint16_t * fltStatus)
      7. 2.4.7  tHCSResponseCode HCS_gotoLPM (tps2hcsxx_man_lpm_exit_curr_ch1_mask_t ch1ExitCurrent, tps2hcsxx_man_lpm_exit_curr_ch2_mask_t ch2ExitCurrent, uint16_t existingValue)
      8. 2.4.8  tHCSResponseCode HCS_gotoSleep (void )
      9. 2.4.9  tHCSResponseCode HCS_initializeDevice (TPS2HCSXXQ1_CONFIG * config)
      10. 2.4.10 tHCSResponseCode HCS_readRegister (uint8_t addr, uint16_t * readValue)
      11. 2.4.11 tHCSResponseCode HCS_setSwitchState (uint8_t swState)
      12. 2.4.12 tHCSResponseCode HCS_updateConfig (TPS2HCS10Q1_CONFIG * config)
      13. 2.4.13 tHCSResponseCode HCS_wakeupDevice (void )
      14. 2.4.14 tHCSResponseCode HCS_writeRegister (uint8_t addr, uint16_t payload)
  6. 3Configuration or Evaluation Tool
  7. 4Code Examples
    1. 4.1 Empty Example
    2. 4.2 I2T Trip Example
    3. 4.3 Low-Power Mode Example
    4. 4.4 Current Sense Example
  8. 5Summary
  9. 6References
  10. 7Revision History

Current Sense Example

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:

  • Input voltage scaling (ISNS_SCALE_CHx of CHx_CONFIG register) is enabled allowing for the ADC input voltage to be scaled by a factor of 8x
  • Open load detection enabled (OL_ON_EN_CHx of CHx_CONFIG) which changes KSNS ratio to lower value (see electrical specs in the data sheet)

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,
                                    &currentValue);
        resCode.byte |=  HCS_readRegister(TPS2HCSXX_ADC_RESULT_CH1_I_REG,
                                    &currentValue).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.