[quote:3dbf1a36e1="Ruprecht"]Or overlooked something?[/quote:3dbf1a36e1]
Try to reduce the prescaler, if you attach pots you likely won't need 10bit resolution.
Prescaler 64 and main clock 20MHz gives you 312,5kHz ADC-clock, while it is above of 50-200kHz, which is described best in regards of resolution, it may be still suitable for manual inputs like pots.
I did not check your bit-notations for correctness, anyway I don't like this:
[code:1:3dbf1a36e1]ADMUX = &b0100_0011[/code:1:3dbf1a36e1]
as it's error prone, better is:
[code:1:3dbf1a36e1]ADMUX = Bits(REFS0, MUX1, MUX0)[/code:1:3dbf1a36e1]
because the meaning is obvious.
Changing the channel is usually done this way:
[code:1:3dbf1a36e1]ADMUX = ADMUX And NBits(MUX3, MUX2, MUX1, MUX0)
ADMUX = ADMUX Or channel[/code:1:3dbf1a36e1]
But as said, I believe you can simply use Bascom's built-in commands, configure the ADC with FREE and then use GetADC(), which is compiled differently by using FREE, it will work non-blocking then, it will set MUX and it will read ADC.
Pseudo-code, not tested:
[code:1:3dbf1a36e1]start:
ch2val = GetADC(chan1) ' dummy read, set MUX to chan1
Do
' wait for 1728 (2 * 13.5 * 64) cycles passing by
ch1val = GetADC(chan2) ' get converted value for previous MUX-setting (chan1) and set new MUX (chan2)
' wait for 1728 (2 * 13.5 * 64) cycles passing by
ch2val = GetADC(chan1) ' vice versa
Loop[/code:1:3dbf1a36e1]
↧