Gast
#881577
Hallo
Habe eine Frage zu einem Beispiel. Und zwar verstehe ich paar sachen
nicht!
interrupt [TIM0_COMPA] void timer0_com(void)
{
// Three sync bytes (00-ff-ff), then 100 data bytes.
PORTB.1 = ~PORTB.1;
// Byte boundary.
if (halfcycle == 16)
{
halfcycle = 0;
voltageD=ADCH;
if (voltageD == 255) voltageD = 0;
ADCSRA.6=1;
if (index == 0) byte = 0x00;
else if (index < 3) byte = 0xff;
else byte = voltageD;
bytenum++;
if (index == 103) index = 0;
}
// On the falling edge of the clock, the output matches the data.
if (halfcycle & 1)
PORTB.0 = (byte >> (halfcycle >> 1)) & 0x01;
// On the rising edge of the clock, the output is the data inverted.
else
PORTB.0 = (~(byte >> (halfcycle >> 1))) & 0x01;
halfcycle++;
}
Also 1. PORTB.1 = ~PORTB.1; es ist ein Output aber was macht es?
2. ist etwas was ich gar nicht verstehe
// On the falling edge of the clock, the output matches the data.
if (halfcycle & 1)
PORTB.0 = (byte >> (halfcycle >> 1)) & 0x01;
// On the rising edge of the clock, the output is the data inverted.
else
PORTB.0 = (~(byte >> (halfcycle >> 1))) & 0x01;
Und zwar Oben hat sich z.B. 1111 1111 (1-byte) gebildet. und jetzt wird
er auf den Ausgang gelegt wenn das Bit 1 ist kommt es in if-Schleife ,
aber das Ergebnis soll ein 01 oder 10 gebildet werden. also
D-Mancheste-Code. d.h. aus 8 bit müssen 16 werden , aber mir ist nicht
ersichtlich wie es 16 wird! Es läuft doch nur 8 mal durch.
Könnte mir einer sagen wie das funktioniert?
Ben