Wer µc.net kennt dürfte leichte Ähnlichkeiten zum Beispiel aus dem
Tutorial erkennen ;)
Mein Problem daran: Beidesmal kommt bitgenau der selbe Wert heraus, halt
einmal rechtsbündig, einmal linksbündig.
Kann es sein, das ich hier schlicht zu schnell hintereinander abfrage?
Weil mit anderem Code, der das deutlich gemächlicher macht, komm ich auf
die gewünschten Ergebnisse. Aber ich warte ja nun extra aufs löschen vom
ADSC-Bit, also sollte sowas doch nicht vorkommen?
Hallo,
vermutlich benutzt Du single conversion mode.
"When changing channel selections, the user should observe the following
guidelines to ensure that the correct channel is selected:
In Single Conversion mode, always select the channel before starting the
conversion. The chan- nel selection may be changed one ADC clock cycle
after writing one to ADSC. However, the simplest method is to wait for
the conversion to complete before changing the channel selection.
In Free Running mode, always select the channel before starting the
first conversion. The chan- nel selection may be changed one ADC clock
cycle after writing one to ADSC. However, the simplest method is to wait
for the first conversion to complete, and then change the channel
selection. Since the next conversion has already started automatically,
the next result will reflect the previous channel selection. Subsequent
conversions will reflect the new channel selection.
When switching to a differential gain channel, the first conversion
result may have a poor accu- racy due to the required settling time for
the automatic offset cancellation circuitry. The user should preferably
disregard the first conversion result."
Mfg
deaktiviere mal die Pullups. Pin im Portx Register auf Low stellen und
dann den Pin im DDRx als Eingang einstellen oder man setzt das PUD =
Pullup disable bit falls der ATMega32 soetwas hat.
Christian S. schrieb:> Hallo,>> vermutlich benutzt Du single conversion mode.
Soweit richtig, ja.
>> "When changing channel selections, the user should observe the following> guidelines to ensure that the correct channel is selected:>> In Single Conversion mode, always select the channel before starting the> conversion.
Hab ich gemacht.
> The chan- nel selection may be changed one ADC clock cycle> after writing one to ADSC. However, the simplest method is to wait for> the conversion to complete before changing the channel selection.
Gewartet hab ich ja auch. Aber der (vermutliche) Fehler war, das ich den
ADC beim zweiten Mal nicht wieder gestartet habe.
Ich hab jetzt noch ein
1
sbiADCSRA,ADSC
eingefügt und bis jetzt läuft das. Ich könnte aber schwören, das es bei
den letzten Tests auch so lief...
Da mein Kanalwert aber in Abhängigkeit des anderen Kanals ordentlich
schwankt (bei GND an einem Kanal -200, bei Vcc +200) muss ich das wohl
eh noch etwas korrigieren.