aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-wdt.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2020-01-30 23:10:25 -0700
committerSelene ToyKeeper2020-01-30 23:10:25 -0700
commitd275f50525ed9a0950c743faa317c7aa4fe9420b (patch)
tree0a288282684a794e4d737289f5adedb0eaf96d02 /spaghetti-monster/fsm-wdt.c
parentswitched to a pseudo-rolling-average method to reduce noise, set prescaler ba... (diff)
downloadanduril-d275f50525ed9a0950c743faa317c7aa4fe9420b.tar.gz
anduril-d275f50525ed9a0950c743faa317c7aa4fe9420b.tar.bz2
anduril-d275f50525ed9a0950c743faa317c7aa4fe9420b.zip
saving state of ADC / WDT refactoring before doing more changes... what changed so far:
- removed LVP lowpass and thermal regulation lowpass logic; it's probably redundant now - slowed ADC deferred logic timing to 4X per second instead of 16X, because there doesn't seem to be much reason to do it any faster - reduced thermal event rate-limit to just 1 second, for more responsive regulation - added "EV_temperature_okay" signal, to help stop adjustments at an appropriate time instead of going to far - sped up sleep LVP to one measurement every 8 seconds instead of 16, to help the aux LEDs respond to voltage changes faster (effect on standby time is negligible) - make sure the WDT doesn't set the ADC channel or counter... except in standby mode
Diffstat (limited to '')
-rw-r--r--spaghetti-monster/fsm-wdt.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/spaghetti-monster/fsm-wdt.c b/spaghetti-monster/fsm-wdt.c
index e9dca3a..459010f 100644
--- a/spaghetti-monster/fsm-wdt.c
+++ b/spaghetti-monster/fsm-wdt.c
@@ -119,7 +119,7 @@ void WDT_inner() {
return; // no sleep LVP needed if nothing drains power while off
#else
// stop here, usually... but proceed often enough for sleep LVP to work
- if (0 != (ticks_since_last & 0x7f)) return;
+ if (0 != (ticks_since_last & 0x3f)) return;
adc_trigger = 255; // make sure a measurement will happen
ADC_on(); // enable ADC voltage measurement functions temporarily
@@ -178,12 +178,15 @@ void WDT_inner() {
#endif
#if defined(USE_LVP) || defined(USE_THERMAL_REGULATION)
- // start a new ADC measurement every 4 ticks
+ // start a new ADC measurement every 16 ticks
adc_trigger ++;
- if (0 == (adc_trigger & 3)) {
- // in case we're in standby mode and auto-retrigger is turned off
+ if (0 == (adc_trigger & 15)) {
+ // 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();
- adc_sample_count = 0;
// allow regulation logic to run
adc_deferred_enable = 1;
}