I'm connecting a DTMF decoder and trying to access pins 4-7 (that's PORTD 4-7) at the same time to get the value. digitalRead() works just fine and I can read the data correctly one bit at a time, but if I try to access PORTD I get all 0s. Here's the code:
byte tone;
tone = (PORTD) >> 4;
Serial.print(tone, HEX);
Serial.print(' ', BYTE);
Serial.print(PORTD, HEX);
Serial.print(' ', BYTE);
Serial.print(DDRD, HEX);
Serial.print(' ', BYTE);
Serial.print(digitalRead(TONE_DETECT) ? '1':'0', BYTE);
Serial.print(' ', BYTE);
Serial.print(digitalRead(Q4) ? '1':'0', BYTE);
Serial.print(digitalRead(Q3) ? '1':'0', BYTE);
Serial.print(digitalRead(Q2) ? '1':'0', BYTE);
Serial.println(digitalRead(Q1) ? '1':'0', BYTE);
Sample output is "0 0 0 1 1110".
What am I doing wrong?
Arduino 07, Mac OS X PPC.
-j