Fixed Last Point error by adding a dummy Last Point = N+1 and then just deleting it after so we get our full range and don't have to fiddle sticks with the timing any more.
This commit is contained in:
parent
e271e9a046
commit
52c6bef53b
29
Impedance.c
29
Impedance.c
|
|
@ -20,6 +20,7 @@ AppIMPCfg_Type AppIMPCfg =
|
|||
|
||||
.ImpODR = 20.0, /* 20.0 Hz = 50ms period */
|
||||
.NumOfData = -1,
|
||||
.RealDataCount = -1, /* Default to no filtering */
|
||||
.SysClkFreq = 16000000.0,
|
||||
.WuptClkFreq = 32000.0,
|
||||
.AdcClkFreq = 16000000.0,
|
||||
|
|
@ -341,7 +342,10 @@ static AD5940Err AppIMPSeqMeasureGen(void)
|
|||
AD5940_SEQGenInsert(SEQ_WAIT(WaitClks/2));
|
||||
AD5940_SEQGenInsert(SEQ_WAIT(WaitClks/2));
|
||||
|
||||
AD5940_AFECtrlS(AFECTRL_ADCCNV|AFECTRL_DFT|AFECTRL_WG, bFALSE);
|
||||
// Stop ADC/DFT first, wait 10us, then stop WG
|
||||
AD5940_AFECtrlS(AFECTRL_ADCCNV|AFECTRL_DFT, bFALSE);
|
||||
AD5940_SEQGenInsert(SEQ_WAIT(16*10));
|
||||
AD5940_AFECtrlS(AFECTRL_WG, bFALSE);
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Measurement 2: Sensor Current (I) */
|
||||
|
|
@ -363,7 +367,10 @@ static AD5940Err AppIMPSeqMeasureGen(void)
|
|||
AD5940_SEQGenInsert(SEQ_WAIT(WaitClks/2));
|
||||
AD5940_SEQGenInsert(SEQ_WAIT(WaitClks/2));
|
||||
|
||||
AD5940_AFECtrlS(AFECTRL_ADCCNV|AFECTRL_DFT|AFECTRL_WG, bFALSE);
|
||||
// Stop ADC/DFT first, wait 10us, then stop WG
|
||||
AD5940_AFECtrlS(AFECTRL_ADCCNV|AFECTRL_DFT, bFALSE);
|
||||
AD5940_SEQGenInsert(SEQ_WAIT(16*10));
|
||||
AD5940_AFECtrlS(AFECTRL_WG, bFALSE);
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Measurement 3: Sensor Voltage (V) */
|
||||
|
|
@ -381,7 +388,11 @@ static AD5940Err AppIMPSeqMeasureGen(void)
|
|||
AD5940_SEQGenInsert(SEQ_WAIT(WaitClks/2));
|
||||
AD5940_SEQGenInsert(SEQ_WAIT(WaitClks/2));
|
||||
|
||||
AD5940_AFECtrlS(AFECTRL_ADCCNV|AFECTRL_DFT|AFECTRL_WG|AFECTRL_ADCPWR, bFALSE);
|
||||
// Stop ADC/DFT first, wait 10us, then stop WG and ADC Power
|
||||
AD5940_AFECtrlS(AFECTRL_ADCCNV|AFECTRL_DFT, bFALSE);
|
||||
AD5940_SEQGenInsert(SEQ_WAIT(16*10));
|
||||
AD5940_AFECtrlS(AFECTRL_WG|AFECTRL_ADCPWR, bFALSE);
|
||||
|
||||
AD5940_AFECtrlS(AFECTRL_HSTIAPWR|AFECTRL_INAMPPWR|AFECTRL_EXTBUFPWR|\
|
||||
AFECTRL_WG|AFECTRL_DACREFPWR|AFECTRL_HSDACPWR|\
|
||||
AFECTRL_SINC2NOTCH, bFALSE);
|
||||
|
|
@ -693,8 +704,20 @@ int32_t AppIMPISR(void *pBuff, uint32_t *pCount)
|
|||
|
||||
AD5940_SleepKeyCtrlS(SLPKEY_UNLOCK);
|
||||
AppIMPDataProcess((int32_t*)pBuff, &FifoCnt);
|
||||
|
||||
// DUMMY POINT FILTERING
|
||||
// If we are in sweep mode and have exceeded the user's requested count,
|
||||
// discard this data packet so the host doesn't see the artifact.
|
||||
if (AppIMPCfg.SweepCfg.SweepEn && AppIMPCfg.RealDataCount > 0) {
|
||||
if (AppIMPCfg.FifoDataCount > AppIMPCfg.RealDataCount) {
|
||||
*pCount = 0; // Discard
|
||||
} else {
|
||||
*pCount = FifoCnt;
|
||||
}
|
||||
} else {
|
||||
*pCount = FifoCnt;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AD5940_SleepKeyCtrlS(SLPKEY_UNLOCK);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ typedef struct
|
|||
/* Application related parameters */
|
||||
float ImpODR; /* */
|
||||
int32_t NumOfData; /* By default it's '-1'. If you want the engine stops after get NumofData, then set the value here. Otherwise, set it to '-1' which means never stop. */
|
||||
int32_t RealDataCount; /* Actual number of valid points to report to host (used for dummy point filtering) */
|
||||
float WuptClkFreq; /* The clock frequency of Wakeup Timer in Hz. Typically it's 32kHz. Leave it here in case we calibrate clock in software method */
|
||||
float SysClkFreq; /* The real frequency of system clock */
|
||||
float AdcClkFreq; /* The real frequency of ADC clock */
|
||||
|
|
|
|||
11
main.c
11
main.c
|
|
@ -203,6 +203,7 @@ void Routine_Measure(float freq) {
|
|||
pCfg->SweepCfg.SweepEn = bFALSE;
|
||||
pCfg->SinFreq = freq;
|
||||
pCfg->NumOfData = -1;
|
||||
pCfg->RealDataCount = -1; // Disable filtering
|
||||
pCfg->bParaChanged = bTRUE;
|
||||
|
||||
if(AppIMPInit(AppBuff, APPBUFF_SIZE) == AD5940ERR_OK) {
|
||||
|
|
@ -222,9 +223,15 @@ void Routine_Sweep(float start, float end, int steps) {
|
|||
pCfg->SweepCfg.SweepEn = bTRUE;
|
||||
pCfg->SweepCfg.SweepStart = start;
|
||||
pCfg->SweepCfg.SweepStop = end;
|
||||
pCfg->SweepCfg.SweepPoints = steps;
|
||||
|
||||
// DUMMY POINT STRATEGY:
|
||||
// Request steps + 1 from the engine, but tell the ISR to only report 'steps'.
|
||||
// The artifact will happen on the +1 point, which is discarded.
|
||||
pCfg->SweepCfg.SweepPoints = steps + 1;
|
||||
pCfg->NumOfData = steps + 1;
|
||||
pCfg->RealDataCount = steps; // Stop reporting after this count
|
||||
|
||||
pCfg->SweepCfg.SweepLog = bTRUE;
|
||||
pCfg->NumOfData = steps;
|
||||
pCfg->bParaChanged = bTRUE;
|
||||
|
||||
if(AppIMPInit(AppBuff, APPBUFF_SIZE) == AD5940ERR_OK) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue