Quellcode durchsuchen

T4: Fix analogReadAveraging

It was not properly clearing the old state for the ADC_CFG_AVGS, but instead it was oring in the new value,

also T4-Analog fix calibration tests
Found by @mjs513 - At init time it was not looking at ADC2 to have completed calibration...

Remove T41b1 pins ifdef
main
Kurt Eckhardt vor 5 Jahren
Ursprung
Commit
3abaeb1142
1 geänderte Dateien mit 4 neuen und 10 gelöschten Zeilen
  1. +4
    -10
      teensy4/analog.c

+ 4
- 10
teensy4/analog.c Datei anzeigen

0, // 7/A7 AD_B1_11 0, // 7/A7 AD_B1_11
13, // 8/A8 AD_B1_08 13, // 8/A8 AD_B1_08
14, // 9/A9 AD_B1_09 14, // 9/A9 AD_B1_09
#if 0
128, // 10
128, // 11
128, // 12
128, // 13
#else
1, // 24/A10 AD_B0_12 1, // 24/A10 AD_B0_12
2, // 25/A11 AD_B0_13 2, // 25/A11 AD_B0_13
128+3, // 26/A12 AD_B1_14 - only on ADC2, 3 128+3, // 26/A12 AD_B1_14 - only on ADC2, 3
128+4, // 27/A13 AD_B1_15 - only on ADC2, 4 128+4, // 27/A13 AD_B1_15 - only on ADC2, 4
#endif
7, // 14/A0 AD_B1_02 7, // 14/A0 AD_B1_02
8, // 15/A1 AD_B1_03 8, // 15/A1 AD_B1_03
12, // 16/A2 AD_B1_07 12, // 16/A2 AD_B1_07
{ {
//printf("wait_for_cal\n"); //printf("wait_for_cal\n");
while (ADC1_GC & ADC_GC_CAL) ; while (ADC1_GC & ADC_GC_CAL) ;
while (ADC2_GC & ADC_GC_CAL) ;
// TODO: check CALF, but what do to about CAL failure? // TODO: check CALF, but what do to about CAL failure?
calibrating = 0; calibrating = 0;
//printf("cal complete\n"); //printf("cal complete\n");
mode1 |= 0; mode1 |= 0;
} }


ADC1_CFG |= mode;
ADC2_CFG |= mode1;
ADC1_CFG = mode;
ADC2_CFG = mode1;
if(num >= 4){ if(num >= 4){
ADC1_GC |= ADC_GC_AVGE;// turns on averaging ADC1_GC |= ADC_GC_AVGE;// turns on averaging
ADC2_CFG = mode | ADC_HC_AIEN | ADC_CFG_ADHSC; ADC2_CFG = mode | ADC_HC_AIEN | ADC_CFG_ADHSC;
ADC2_GC = avg | ADC_GC_CAL; // begin cal ADC2_GC = avg | ADC_GC_CAL; // begin cal
calibrating = 1; calibrating = 1;
while (ADC1_GC & ADC_GC_CAL) ;
while (ADC2_GC & ADC_GC_CAL) ;
calibrating = 0; calibrating = 0;
} }



Laden…
Abbrechen
Speichern