I am aware I can address eg. DDRB register by name, but I want to access the registers by number, essentially reading /writing directly to an I/O register (eg. port 0x04 for DDRB).
I want to do this in a loop (and I want to be able to initiate it from the attached PC).
How can I read or write directly from/to an AVR's I/O register by number?
Line 3 compiles just fine; Line 4 will not compile and would mean something entirely different than to manipulate controller registers.
@Graynomad: I want to be able to send an instruction from my PC to Arduino, saying "what is the current value of DDRB?" If I have to program all registers in an 'if' or 'case' statement, I will probably make many errors and the program will grow really quick in size.
If you check the datasheet of ATmega1280, you'll see DDRB is a register at I/O port 0x04. If you examine the disassembled machine code that is sent to the controller while programming it, you'll see writing to IO ports is simply reading an IO register. I do not mean pin 0x04.
will never compile. I need some way to tell the compiler to access the AVR's register, not the number. Any idea where I can find the DDRx macro? Maybe I can figure it out from the source codes.