diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDeviceCorrection.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDeviceCorrection.h index 1d8979832..dbb93927a 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDeviceCorrection.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDeviceCorrection.h @@ -725,7 +725,8 @@ static int32_t DecodeADCValue(uint8_t ADCGain, uint8_t ADCChannel, uint8_t *ADC_ // return real current to controller else if(ADCChannel == ADC_CH_CURRENT){ - if ( (INSTRUCTION.eliteFxn == IV_CURVE) || (INSTRUCTION.eliteFxn == CV_CURVE)) { +// if ( (INSTRUCTION.eliteFxn == IV_CURVE) || (INSTRUCTION.eliteFxn == CV_CURVE)) { + if ( (INSTRUCTION.eliteFxn == CV_CURVE)) { // wait 0.1 sec until circuit stable => discard first data means wait 0.1 sec if(DiscardIVFirstData){ DiscardIVFirstData ++; diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteIVCurve.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteIVCurve.h index 0396f0777..0be902375 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteIVCurve.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteIVCurve.h @@ -88,6 +88,7 @@ static uint16_t OneWayVoltScan(IVMode *IV) { static void IV_Plot(IVMode *IV) { static uint8_t VoltCurrentSwitch = 0; + static uint8_t PreviousGain = GAIN_200R; uint16_t ADC_measure = 0; if(VoltCurrentSwitch < 5){ @@ -96,10 +97,23 @@ static void IV_Plot(IVMode *IV) { } else if(VoltCurrentSwitch == 5){ // read current - ReadCurrent(spi_ADC_rxbuf); - ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]); - IV->_MeasureData = DecodeADCCurrent(INSTRUCTION.ADCGainLevel, ADC_measure); - VoltCurrentSwitch ++; + + if(INSTRUCTION.AutoGainEnable){ + IV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf); + while(PreviousGain != INSTRUCTION.ADCGainLevel){ + PreviousGain = INSTRUCTION.ADCGainLevel; + IV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf); + } + } + else{ + ReadCurrent(spi_ADC_rxbuf); + IV->_MeasureData = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf); + } + +// ReadCurrent(spi_ADC_rxbuf); +// ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]); +// IV->_MeasureData = DecodeADCCurrent(INSTRUCTION.ADCGainLevel, ADC_measure); +// VoltCurrentSwitch ++; } else if(VoltCurrentSwitch <9){ // read volt