Kantega rašė:
> while(1){
> WriteByteToDOG(0x01, DOG_CMD); //clrscr
> ADCSRA |= _BV(ADSC); //start conversion
> while (!F_ADCIRQ);
> F_ADCIRQ = 0;
> ADCResult = (ADCH<<8)|ADCL;
> //ADCResult = ADC5_PIN; cia nuskaitymas skaitmeniame rezime, veikia
> WriteShortToDisplay(ADCResult);
> ADCResult = 0;
> _delay_ms(1000);
> LED1 = !LED1;
> }//while 1
> }// main
Manuale yra tokia pastraipa:
„The ADC generates a 10-bit result which is presented in the ADC Data
Registers, ADCH and ADCL. _By_ _default_, the result is presented
_right_ _adjusted_, but can optionally be presented left adjusted by
setting the ADLAR bit in ADMUX.
*If* the result is _left_ _adjusted_ and no more than 8-bit precision is
required, it is sufficient to read ADCH. *Otherwise* _ADCL_ _must_ _be_
_read_ _first_, _then_ _ADCH_, _to_ _ensure_ _that_ _the_ _content_ _of_
_the_ _Data_ _Registers_ _belongs_ _to_ _the_ _same_ _conversion_. Once
ADCL is read, ADC access to Data Registers is blocked. This means that
if ADCL has been read, and a conversion completes before ADCH is read,
neither register is updated and the result from the conversion is lost.
When ADCH is read, ADC access to the ADCH and ADCL Registers is re-enabled.“
Taigi, ar negalėtų būti taip, kad C sintaksės eilutė
ADCResult = (ADCH<<8)|ADCL;
asemblerio mnemonikoje taip, eilės tvarka, ir išsireiškia, _visų_
_pirma_ _į_ _ADCH_ _skaitymą_ (gauni reikšmę ir ADC priėjimas prie
ADCH/ADCL registrų _atblokuojamas_), _o_ _po_ _to_ _į_ _ADCL_ _skaitymą_
(gauni reikšmę ir iš karto *užblokuojamas* _ADC_ _priėjimas_ _prie_
_ADCH/ADCL_ _registrų_).
Sekančiu ciklu, paleidus konversiją ir jai įvykus, ADC tiesiog negali
įrašyti rezultato į ADCH/ADCL (nes tai užblokuota), o paeilinis
ADCH/ADCH skaitymas duoda tas pačias pirmos konversijos reikšmes ir
velnio ratas (atblokuojant ir vėl užblokuojant ADC priėjimą prie
registrų) tęsiamas.