uint16_t sensorinpucap(uint8_t b) { uint8_t timeraltlow, timeralthigh ; uint16_t timerneulow, timerneuhigh; uint16_t difflow=0, diffhigh=0; uint16_t tdi=0, td=0; cli(); /* keine Interrupts */ /* Input-capture-Einstellung zur Ermittlung von th bzw. tg: */ /* set TCCR1B 0-ICESI-0-0-CTC1-CS12-CS11-CS10 */ /* 0-1(steig.Fla)-0-0-0-0-0-1(CPU-Takt) = 65, */ /* d.h. steigende Flanke: TCCR1B = 65, fallende Flanke TCCR1B = 1*/ /* ggf. zzgl. 128 für Rauschunterdrückung (193 bzw. 129) */ for (i=1; i<31; i++) /* cave overflow bei höheren Temp.! */ { label1:; tdi=0,difflow=0, diffhigh=0; TIFR = (1<high=193*/ while (!(TIFR & _BV(ICF1))); /* warten auf nächsten Wechsel */ /* wenn low: auslesen */ timeraltlow = inp (TCNT1L); /* TCNT1L<-- zählerlow; low zuerst */ timeralthigh = inp (TCNT1H); /* TCNT1H<-- zählerhigh */ /* TCCR1B neu setzen */ TCCR1B =b ; /* a=65 für low->high (zg), 1 für high->low (zh)*/ TIFR = (1<= (timeralthigh*255 + timeraltlow) ) /* = 0, wenn falsch --> skip via else zu erneuter Abfrage */ { difflow = timerneulow - timeraltlow; diffhigh = timerneuhigh - timeralthigh; tdi=(diffhigh*255+difflow); } /*Ende if */ else { goto label1; } /* Ende else */ td +=tdi; } return td; } /* Ende sensorinpucap */