diff options
| author | Selene ToyKeeper | 2023-07-08 03:55:02 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2023-07-08 03:55:02 -0600 |
| commit | 7400cbf6a1370035400607c22d57366c54304fb9 (patch) | |
| tree | cb035598852203bb92a36cd63f2039e79c1c0b59 /spaghetti-monster | |
| parent | added Noctigon M44 sources (diff) | |
| download | anduril-7400cbf6a1370035400607c22d57366c54304fb9.tar.gz anduril-7400cbf6a1370035400607c22d57366c54304fb9.tar.bz2 anduril-7400cbf6a1370035400607c22d57366c54304fb9.zip | |
Fixed spurious voltage warnings in attiny1616 sleep mode. Fixed by SammysHP.
https://budgetlightforum.com/t/anduril-2-feature-change-suggestions/218045/467
I was never able to reproduce the issue here, but the fix seems good and others
tested it successfully.
Diffstat (limited to '')
| -rw-r--r-- | spaghetti-monster/fsm-adc.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/spaghetti-monster/fsm-adc.c b/spaghetti-monster/fsm-adc.c index a196b7b..d11cca8 100644 --- a/spaghetti-monster/fsm-adc.c +++ b/spaghetti-monster/fsm-adc.c @@ -83,11 +83,6 @@ inline void adc_sleep_mode() { // attiny1634 set_sleep_mode(SLEEP_MODE_ADC); #elif defined(AVRXMEGA3) // ATTINY816, 817, etc - // set the RUNSTDBY bit so ADC will run in standby mode - ADC0.CTRLA |= 1; - // set a INITDLY value because the AVR manual says so - // (section 30.3.5) - ADC0.CTRLD |= (1 << 5); set_sleep_mode(SLEEP_MODE_STANDBY); #else #error No ADC sleep mode defined for this hardware. @@ -133,10 +128,13 @@ inline void ADC_on() ADCSRA = (1 << ADEN) | (1 << ADSC) | (1 << ADATE) | ADC_PRSCL; //ADCSRA |= (1 << ADSC); // start measuring #elif defined(AVRXMEGA3) // ATTINY816, 817, etc - set_admux_voltage(); VREF.CTRLA |= VREF_ADC0REFSEL_1V1_gc; // Set Vbg ref to 1.1V - ADC0.CTRLA = ADC_ENABLE_bm | ADC_FREERUN_bm; // Enabled, free-running (aka, auto-retrigger) - ADC0.COMMAND |= ADC_STCONV_bm; // Start the ADC conversions + // Enabled, free-running (aka, auto-retrigger), run in standby + ADC0.CTRLA = ADC_ENABLE_bm | ADC_FREERUN_bm | ADC_RUNSTBY_bm; + // set a INITDLY value because the AVR manual says so (section 30.3.5) + // (delay 1st reading until Vref is stable) + ADC0.CTRLD |= ADC_INITDLY_DLY16_gc; + set_admux_voltage(); #else #error Unrecognized MCU type #endif @@ -144,7 +142,7 @@ inline void ADC_on() inline void ADC_off() { #ifdef AVRXMEGA3 // ATTINY816, 817, etc - ADC0.CTRLA &= ~(ADC_ENABLE_bm); // disable the ADC + ADC0.CTRLA &= ~(ADC_ENABLE_bm); // disable the ADC #else ADCSRA &= ~(1<<ADEN); //ADC off #endif |
