perhaps some special function has taken over the port pin? looks like the '644 has serial and some timer outputs sharing port D with gpio. the special functions usually override port bits when enabled.
Also, reading the PORT register instead of PIN can cause significant confusion- PORT returns the saved output value used when the port is an output, whereas the PIN register returns the actual digital value present on the pin in that instant.
-----------------------------------------------
Wooden Mendel
Teacup Firmware