I am playing with port registers directly to improve speed on a Arduino micro. I have no problem writing them, like
PORTF &= B11101111
However, when I try to read and print it, things get funny and I hope to know why.
byte dat = PORTF; Serial.print(dat,BIN);
produces a single 0, where I am expecting 8 0's as for a byte. And, even when I check that a digitalRead correctly gets a 1 from PF5 or A2,
byte dat = PORTF; Serial.print(dat,BIN); Serial.print(dat,BIN);
produces a compiler error like
...cores\arduino\Print.cpp: In function 'println.constprop': ...cores\arduino\Print.cpp:143:1: internal compiler error: Segmentation fault } ^