diff options
| author | Selene ToyKeeper | 2019-11-19 00:21:15 -0700 |
|---|---|---|
| committer | Selene ToyKeeper | 2019-11-19 00:21:15 -0700 |
| commit | 492fdf3281aa7bbcb5aa37b10420766b433e8d34 (patch) | |
| tree | b45466090f72d78ecd2a31b4acfeab6b50065035 /spaghetti-monster | |
| parent | cleaned up WDT code a bit, reduced total size, (diff) | |
| download | anduril-492fdf3281aa7bbcb5aa37b10420766b433e8d34.tar.gz anduril-492fdf3281aa7bbcb5aa37b10420766b433e8d34.tar.bz2 anduril-492fdf3281aa7bbcb5aa37b10420766b433e8d34.zip | |
fixed ADC cycles running 2X as fast as intended
Diffstat (limited to '')
| -rw-r--r-- | spaghetti-monster/fsm-adc.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/spaghetti-monster/fsm-adc.c b/spaghetti-monster/fsm-adc.c index c859539..ccf1ca2 100644 --- a/spaghetti-monster/fsm-adc.c +++ b/spaghetti-monster/fsm-adc.c @@ -108,12 +108,12 @@ static inline uint8_t calc_voltage_divider(uint16_t value) { } #endif -// Each full cycle runs 7.8X per second with just voltage enabled, -// or 3.9X per second with voltage and temperature. +// Each full cycle runs 15.6X per second with just voltage enabled, +// or 7.8X per second with voltage and temperature. #if defined(USE_LVP) && defined(USE_THERMAL_REGULATION) -#define ADC_CYCLES_PER_SECOND 4 -#else #define ADC_CYCLES_PER_SECOND 8 +#else +#define ADC_CYCLES_PER_SECOND 16 #endif #ifdef USE_THERMAL_REGULATION @@ -322,13 +322,13 @@ static inline void ADC_temperature_handler() { // if it's time to rotate the thermal history, do it history_step ++; #if (THERMAL_UPDATE_SPEED == 4) // new value every 4s - #define THERM_HISTORY_STEP_MAX 15 + #define THERM_HISTORY_STEP_MAX ((2*ADC_CYCLES_PER_SECOND)-1) #elif (THERMAL_UPDATE_SPEED == 2) // new value every 2s - #define THERM_HISTORY_STEP_MAX 7 + #define THERM_HISTORY_STEP_MAX (ADC_CYCLES_PER_SECOND-1) #elif (THERMAL_UPDATE_SPEED == 1) // new value every 1s - #define THERM_HISTORY_STEP_MAX 3 + #define THERM_HISTORY_STEP_MAX ((ADC_CYCLES_PER_SECOND/2)-1) #elif (THERMAL_UPDATE_SPEED == 0) // new value every 0.5s - #define THERM_HISTORY_STEP_MAX 1 + #define THERM_HISTORY_STEP_MAX ((ADC_CYCLES_PER_SECOND/4)-1) #endif if (0 == (history_step & THERM_HISTORY_STEP_MAX)) { // rotate measurements and add a new one |
