This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM5728: Using Current Monitoring feature of PMIC TPS659038 on AM5728

Part Number: AM5728
Other Parts Discussed in Thread: TPS659037

I'm trying to measure the SMPS current values from TPS65038 (PMIC powering my AM5728 platform) following the description of the feature in the 6.3.2.1.3 Current Monitoring and Short Circuit Detection [1] . 

#!/bin/bash

# From 5.12 Electrical Characteristics: 12-Bit Sigma-Delta ADC I_FS0=3.958 I_OS0=0.652
# Dual-phase SMPS45
K=2 #GPADC_SMPS_ILMONITOR_EN - Enable current monitoring on SMPS 45 i2cset -f -y 0 0x59 0xD4 0x22 #GPADC_AUTO_SELECT - Auto Conversion enabled on ADC Channel 11: i2cset -f -y 0 0x59 0xC8 0x0B #GPADC_AUTO_CTRL - Enable Conversion i2cset -f -y 0 0x59 0xC3 0x30 # Read Channel 11 MSB0=`i2cget -f -y 0 0x59 0xCA` MSB0=$((($MSB0 & 16#FFF) << 8)) LSB0=`i2cget -f -y 0 0x59 0xC9` CODE0=$(($MSB0 | $LSB0)) echo $(perl -e "print (((($CODE0*$I_FS0*$K)/(4096 - 1)) - ($I_OS0*$K)))")

This script is giving me a negative value all the time:

./getSMPS45Current.sh

-1.29820073260073

May I please have someone check my script? 

Thank you,

Adam

[1] https://www.ti.com/lit/ds/symlink/tps659038-q1.pdf?ts=1601989717855&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FTPS659038-Q1