czyzby bug w atmega640?

Hej mam sobie taki problem w mega640 jest sobie ADC, pedzony z 250kHz, trygerowany z timera T0, sygnalem compare MATCHA no i wszystko smiga pieknie, dostaje przerwania od ADC co zalozony czas. Dla celow debugowych sobie wlaczylem generacje sygnalu prostokatnego na OC0A Problem jest gdy wylacze przerwanie od T0 - ADC staje, pomimo ze sygnal na OC0A sobie nadal jest..

Na razie rozwiazalem to tak:

void (TIMER0_COMPA_vect) (void) __attribute__ ((signal, __INTR_ATTRS)) __attribute__((naked)); void (TIMER0_COMPA_vect) (void) //timer 0 interrupt - not used, T0 is used to generate the ADC clock only //SIGNAL(TIMER0_COMPA_vect) //debug interrupt ftom timer 0 { asm("reti"); }

czyli pozwalam mu wejsc do przerwania po to by zaraz wyjsc. Dziala, ale to nieeleganckie. Ma ktos z Was pomysl o co chodzi? Wyglada tak, jakby cos blokowalo przerwanie od ADC. Czyzby nieobsluzone wylaczone przerwanie od T0? troche to bez sensu, aczkolwiek kiedys przerabialem taki problem w prockach Cypressa.

konfiguracja ADC:

//ADC init, ext REF,left adjust (8 bit mode), MUX= ADC0, MUX5 switches between ADC15..8 and ADC7..0 ADMUX = (1<<ADLAR); //enable ADC,start first conversion, auto trigger enabled,enable ADC interrupt, ADCSRA = (1<<ADEN)| (1<<ADATE)| (1<<ADIE)| (1<<ADPS2) | (1<<ADPS0); //mux5 disabled,enable triggering by the timer T0 compare match A - CTC mode ADCSRB = (0<<MUX5) | (1<<ADTS1)| (1<<ADTS0);

konfiguracja T0

TCCR0A = (1<<WGM01) | (1<<COM0A0) ; // mode CTC TCCR0B = (0<<CS01)|(0<<CS00); // prescaller /64 -> 250kHz -> 4us clk period,//stop T0 at the moment OCR0A = 100; //enter some value to avoid generation of excessive interrupts TIMSK0 = (1<<OCIE0A); // enable T0 interrupts.

ADCSRA |= (1<<ADIF); //clear pending ADC interrupts ADCSRA |= (1<<ADSC); //start 1-st conversion

Reply to
Greg(G.Kasprowicz
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.