From 54bcb0efe2032ef0fe797aa8d2015706d288e965 Mon Sep 17 00:00:00 2001 From: Taylor Liao Date: Mon, 23 Aug 2021 19:42:37 +0800 Subject: [PATCH] 100Hz down same data --- .../cc26xx/app/headstage/AD5940.h | 1 + .../cc26xx/app/headstage/EliteADC.h | 24 ++++++++++++++++++- .../cc26xx/app/headstage/EliteEISMode.h | 2 ++ .../cc26xx/app/headstage/Elite_mode_ADC_DAC.h | 14 +++++++++-- .../cc26xx/app/headstage/Elite_version.h | 4 ++-- .../cc26xx/app/headstage/headstage.h | 8 +++---- .../cc26xx/app/headstage/impedance_meter.h | 6 +---- 7 files changed, 45 insertions(+), 14 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/AD5940.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/AD5940.h index cadc851cc..e617db3ca 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/AD5940.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/AD5940.h @@ -60,6 +60,7 @@ static void setEIS_EIS (void) if (instru.ADCGainLv != HSRTIA_GAIN_AUTO) { instru.AutoGainEnable = 0; + HSTIAGainCtrl(instru.ADCGainLv); } else { instru.AutoGainEnable = 1; instru.ADCGainLv = HSRTIA_200R; diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteADC.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteADC.h index 90853d07b..104e2b37e 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteADC.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteADC.h @@ -333,11 +333,17 @@ static int32_t ReadRawADC() { } static int32_t ReadRealZ() { + select_REG(DFTREAL); + r32_REG(); + CPUdelay(10); select_REG(DFTREAL); return r32_REG(); } static int32_t ReadImagZ() { + select_REG(DFTIMAG); + r32_REG(); + CPUdelay(10); select_REG(DFTIMAG); return r32_REG(); } @@ -709,7 +715,7 @@ static int32_t read_LPTIA_Iin(){ static uint32_t read_HSTIA_Iin(){ static uint32_t originalDFT, RealCurrent, RealCurrentRMS, correctedDFT, freq, cutoff; - Elite_led_color(COLOR_PURPLE); +// Elite_led_color(COLOR_PURPLE); instru.real = neg_18bit(ReadRealZ()); instru.imag = neg_18bit(ReadImagZ()); @@ -1108,6 +1114,12 @@ static void GetAvgData(uint8_t index){ // InputNotify(NOTIFY_IMPEDANCE, avgPhaseData[index]); } + +static int32_t r_sinc2dat(){ + select_REG(0x2080); + return r32_REG(); +} + static void CalcAvg(uint8_t avg_num){ struct wm_eis_ctx_t *eis = (struct wm_eis_ctx_t *)wm_get(); uint16_t i; @@ -1159,6 +1171,15 @@ static void EnSinc2(uint8_t ret){ // 1: enable, 0: disable // w32_REG(code2); } +static void EnNotch(uint8_t ret){ + uint32_t code; + + select_REG(0x2044); + code = r32_REG(); + code = (code & (~(1 << 4))) | (!ret << 4); + w32_REG(code); +} + static void SetSinc3OSR(uint8_t osr){ //0, 1, 2, 3 uint32_t code; @@ -1229,6 +1250,7 @@ static uint32_t SetSamplingTime(uint32_t freq){ else if (freq >= 1000) { // EnSinc2(1); SelDFTin(3); + EnNotch(1); SetADCDataRate(ADC800Ksps); SetSinc2OSR(Sinc2OSR22); SetSinc3OSR(Sinc3OSR5); diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteEISMode.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteEISMode.h index 6fe03354f..0039d2792 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteEISMode.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteEISMode.h @@ -21,6 +21,8 @@ static void eis_fscan(void) eis->_decades = CalcDecade(instru.fmin, instru.fmax); instru.fset = eis->_f1; + + vscanReset = false; } if (!vscanReset) { diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_mode_ADC_DAC.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_mode_ADC_DAC.h index ea30999f9..72f393dfe 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_mode_ADC_DAC.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_mode_ADC_DAC.h @@ -478,24 +478,34 @@ static void EIS_Plot(void) //real and imag impedance plot ADC_cnt ++; instru.sampleRate = 15; } - else if (ADC_cnt == 1) { + else if (ADC_cnt == 1){ read_HSTIA_Iin(); +// HSTIA_change_gain(); ADC_cnt ++; +// instru.sampleRate = 15; } else if (ADC_cnt == 2) { read_HSTIA_Iin(); +// ReadImagZ(); ADC_cnt ++; } else if (ADC_cnt == 3) { read_HSTIA_Iin(); +// imag = ReadImagZ(); + ADC_cnt ++; } else if (ADC_cnt == 4) { read_HSTIA_Iin(); +// ReadRealZ(); ADC_cnt ++; } else if (ADC_cnt == 5) { - Elite_led_color(COLOR_CYAN); + read_HSTIA_Iin(); +// real = ReadRealZ(); + ADC_cnt ++; + } + else if (ADC_cnt == 6) { notify_flag = true; ADC_cnt = 0; } diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h index 8fd9fe237..690ffa53b 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h @@ -3,8 +3,8 @@ #define VERSION_DATE #define VERSION_DATE_YEAR 21 -#define VERSION_DATE_MONTH 6 -#define VERSION_DATE_DAY 17 +#define VERSION_DATE_MONTH 9 +#define VERSION_DATE_DAY 9 #define VERSION_DATE_HOUR 12 #define VERSION_DATE_MINUTE 18 diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h index 3eb3102fe..90c63a42e 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h @@ -691,9 +691,9 @@ static void update_ZM_instruction(uint8 *ins) { switch (ins[2]) { case CURVE_EIS: { //0xD1 if (ins[3] == PARA_1) { //3000D1 01 - instru.f1 = 67114;//((uint32_t)(ins[4]) << 24) | ((uint32_t)(ins[5]) << 16) | ((uint32_t)(ins[6]) << 8) | (uint32_t)(ins[7]); //FREQ_START - instru.f2 = 67;//((uint32_t)(ins[8]) << 24) | ((uint32_t)(ins[9]) << 16) | ((uint32_t)(ins[10]) << 8) | (uint32_t)(ins[11]); //FREQ_STOP - instru.sampleRate = CalcDelayTime(instru.f1, true); //ms //read + instru.f1 = 67;//((uint32_t)(ins[4]) << 24) | ((uint32_t)(ins[5]) << 16) | ((uint32_t)(ins[6]) << 8) | (uint32_t)(ins[7]); //FREQ_START + instru.f2 = 6711409;//((uint32_t)(ins[8]) << 24) | ((uint32_t)(ins[9]) << 16) | ((uint32_t)(ins[10]) << 8) | (uint32_t)(ins[11]); //FREQ_STOP + instru.sampleRate = CalcDelayTime(User2Freq(instru.f1), true); //ms //read instru.fmax = (uint32_t)VMAX(instru.f1, instru.f2); instru.fmin = (uint32_t)VMIN(instru.f1, instru.f2); instru.delay = 10;//((uint16_t)(ins[12]) << 8) | (uint16_t)(ins[13]); //DELAY/10 how many periods @@ -709,7 +709,7 @@ static void update_ZM_instruction(uint8 *ins) { instru.dcbias = 0;//((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]); instru.acamp = 26;//((uint16_t)(ins[6]) << 8) | (uint16_t)(ins[7]); instru.avgnum = 0;//(uint8_t)(ins[8]); - instru.rtia = 4;//(uint8_t)(ins[9]); + instru.rtia = 0;//(uint8_t)(ins[9]); instru.ppd = 10;//((uint16_t)(ins[10]) << 8) | (uint16_t)(ins[11]); instru.scale = 0;//(uint8_t)(ins[12]); diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/impedance_meter.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/impedance_meter.h index 14f429e36..9d34f33be 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/impedance_meter.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/impedance_meter.h @@ -133,7 +133,7 @@ static void SimpleBLEPeripheral_performPeriodicTask(void) { GPT.GptimerCounter0 = GPT.GptimerCounter; if (mode_init){ - GPT.SampleRateCounter = instru.sampleRate - 10; + GPT.SampleRateCounter = 0; mode_init = false; record_flag = true; fset_flag = true; @@ -162,10 +162,6 @@ static void SimpleBLEPeripheral_performPeriodicTask(void) { } first_highz_flag = false; } else { - if (notifyFirst_flag) { - GPT.NotifyCounter = instru.notifyRate - 20; - notifyFirst_flag = false; - } vscanReset = false; leadTimeReset = false; }