diff options
| author | Selene ToyKeeper | 2020-03-16 00:13:44 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2020-03-16 00:13:44 -0600 |
| commit | 6e7884cf5b4756ffba9f6dc9dd1fb94184779bf1 (patch) | |
| tree | 7e99a01ee2d002e43fa8241e11a0c0f148d02267 /spaghetti-monster | |
| parent | reduced regulation jitter by biasing errors toward zero by a constant amount, (diff) | |
| download | anduril-6e7884cf5b4756ffba9f6dc9dd1fb94184779bf1.tar.gz anduril-6e7884cf5b4756ffba9f6dc9dd1fb94184779bf1.tar.bz2 anduril-6e7884cf5b4756ffba9f6dc9dd1fb94184779bf1.zip | |
cleaned up WDT ADC timer code slightly, and removed a bit of redundant code
Diffstat (limited to '')
| -rw-r--r-- | spaghetti-monster/fsm-wdt.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/spaghetti-monster/fsm-wdt.c b/spaghetti-monster/fsm-wdt.c index 1d630a4..9858e09 100644 --- a/spaghetti-monster/fsm-wdt.c +++ b/spaghetti-monster/fsm-wdt.c @@ -111,7 +111,7 @@ void WDT_inner() { #ifdef TICK_DURING_STANDBY // handle standby mode specially if (go_to_standby) { - // emit a halfsleep tick, and process it + // emit a sleep tick, and process it emit(EV_sleep_tick, ticks_since_last); process_emissions(); @@ -121,7 +121,7 @@ void WDT_inner() { // stop here, usually... but proceed often enough for sleep LVP to work if (0 != (ticks_since_last & 0x3f)) return; - adc_trigger = 255; // make sure a measurement will happen + adc_trigger = 0; // make sure a measurement will happen ADC_on(); // enable ADC voltage measurement functions temporarily #endif } @@ -178,18 +178,20 @@ void WDT_inner() { #endif #if defined(USE_LVP) || defined(USE_THERMAL_REGULATION) - // enable the deferred ADC handler every 32 ticks - adc_trigger ++; - if (0 == (adc_trigger & 31)) { + // enable the deferred ADC handler once in a while + if (! adc_trigger) { + /* redundant; it was already turned on earlier in this function // in case we're in standby mode and the ADC is turned off if (go_to_standby) { //set_admux_voltage(); ADC_on(); } + */ ADC_start_measurement(); - // allow regulation logic to run adc_deferred_enable = 1; } + // timing for the ADC handler is every 32 ticks (~2Hz) + adc_trigger = (adc_trigger + 1) & 31; #endif } |
