Hi !

Ich habe hier ein kleines problem beim umschalten der adc Kanähle...
Irgendwie scheinen sie sich gegenseitig zu beeinflussen....
was mache ich hier falsch ? werde nicht schlau draus...

Würde mich über jedliche hilfe freuen !
Code:
//CLK = 8MHz Timer0 = 100KHz ADC = 62,5KHz //Controller = Tiny85
#include <avr/io.h>
#include <stdio.h>
#include <stdlib.h>
#include <util/delay.h>
#include <avr/interrupt.h>

#define T0REL 176

#define LEDS PORTB
#define LED1 2
#define LED2 4

volatile int _adc2 = 0;
volatile int _adc3 = 0;
volatile int _timer = 0;

void cfgPorts(void)                                
{
    DDRB = 0b00000110;                                
    PORTB = 0b00000000;
}

void cfgTimer0(void)                            
{
    TCNT0 = T0REL;                                
    TCCR0B |= (1<<CS00);                        
    TIMSK |=(1<<TOIE0);                                
}

void cfgAdc(void)
{
    ADCSRA|= (1<<ADEN);
    ADCSRA |= (1<<ADPS1);
    ADCSRA |= (1<<ADPS2);
    ADCSRA |= (1<<ADPS0);
        
    ADMUX &=~ (1<<REFS0);
    ADMUX |= (1<<MUX0);
    ADMUX |= (1<<MUX1);
}

int getAdc(unsigned char channel) 
{
    int output=0;
    ADMUX = channel;
    ADCSRA |= (1<<ADSC);
     
    //while (!(ADCSRA & (1<<ADIF)))
    while ((ADCSRA & (1<<ADSC)))
    {
        output = ADCL | (ADCH<<8);
    }
    return output;
}

void enableInterrupts(void)                                
{
    SREG |= 128;                                
}

int main(void)
{
    cfgPorts();
    cfgTimer0();
    cfgAdc();
    enableInterrupts();

    while(1)
    {
        _adc2 = getAdc(2);
        _adc3 = getAdc(3);
        _delay_ms(10);
    }
    return 0;
}

//soft pwm für Anzeige Leds
ISR(TIMER0_OVF_vect)
{
    TCNT0 = T0REL;
    if(_timer++> 1024)_timer = 0;
    
    if(_adc2 > _timer)
    {
        LEDS |= LED1;
    }else
    {
        LEDS &=~ LED1;
    }        
    if(_adc2 > _timer)
    {
        LEDS |= LED2;
    }else
    {
        LEDS &=~ LED2;
    }
}
achso am adc hängen 2 potis an dem einen 10K an dem anderen 100K

wenn ich nur einen adc auslese funktioniert alles wunderbar...

Mfg Fugitivus