diff --git a/DCCTimerAVR.cpp b/DCCTimerAVR.cpp index 3e45ae8..5ff0e52 100644 --- a/DCCTimerAVR.cpp +++ b/DCCTimerAVR.cpp @@ -126,6 +126,7 @@ void DCCTimer::reset() { #endif uint16_t ADCee::usedpins = 0; int * ADCee::analogvals = NULL; +bool ADCusesHighPort = false; /* * Register a new pin to be scanned @@ -136,6 +137,8 @@ int ADCee::init(uint8_t pin) { uint8_t id = pin - A0; if (id > NUM_ADC_INPUTS) return -1023; + if (id > 7) + ADCusesHighPort = true; pinMode(pin, INPUT); int value = analogRead(pin); if (analogvals == NULL) @@ -196,7 +199,15 @@ void ADCee::scan() { while (true) { if (mask & usedpins) { // start new ADC aquire on id - ADMUX=(1< 7) // if we use a high ADC pin + bitSet(ADCSRB, MUX5); // set MUX5 bit + else + bitClear(ADCSRB, MUX5); + } +#endif + ADMUX=(1<setBrake(1); waiting = true;