Switch on a LED: why doesn't this code work?
if ((PTDD_PTDD2 |= 0x02))


This is equal to:

PTDD_PTDD2 |= 0x02;
if (1)


This does probably not what you want either:

PTFD_PTFD0 &amp;=0x01;


The resulting value of PTFD_PTFD0 is 0x00 or 0x01, depending on the value of least sigificant Bit. 

It looks like you wanted: 

PTFD_PTFD0 &amp;= ~ 0x01;


This sets the LSB to zero.