This is regarding the mega2560 and I cannot figure out this strange behavior. If relevant, I'm using an Arduino Mega2560 and Atmel Studio 7.0. I am not using any Arduino libraries.
It's regarding this line:
PORTL |= (1 << PL3);
I'm debugging this with serial communication.
Immediately before this line, PORTL contains 00000000 and PINL contains 00000000.
Immediately after this line, PORTL contains 00001000 and PINL contains 00001110.
As I understand, PINL should be 00001000 after that line, not 00001110. Toggling a single PORT bit should change only a single PIN bit right?
I've also tried debugging this with Atmel ICE. Toggling a single PORTL bit through I/O View also sometimes toggles multiple PINL bits. I'm also not using any of the alternate functions of PORTL (no Timer 5 in the rest of my code, no Timer 4 Input Capture either).
I don't want to show the rest of the code because it's really long. But what could cause this kind of behavior?