AVR registers: DDR, PORT, PIN and the timers by hand
Take the Arduino wrapper off the Uno: set pins with registers, run Timer 1 yourself, follow the vector table and count cycles in assembly.
How you will learn it
Every pinMode() and digitalWrite() ends up as a write to an AVR register. Knowing those registers means faster code, precise timing and the ability to read any datasheet, which is why firmware jobs ask about them.
Under the hood does it on a simulated Arduino Uno: DDR, PORT and PIN for the pins, Timer 1 set up by hand, the vector table behind interrupts, a cycle-counted delay in a .S file, a halt read in the debugger and a protocol bit-banged from scratch.
What you will learn
- Set pin direction and level with DDRx and PORTx, and read PINx.
- Configure Timer 1 by hand for exact timing.
- Write an interrupt handler and know how the vector table finds it.
- Write cycle-counted assembly and read a halt in the debugger.
The courses and lessons to take
Every lesson opens in the editor right away, signed in or not, and the simulator checks each step.
- Step 1 · 6 lessons · 5 h
Under the hood
The whole course.
- DDR, PORT and PINThe three registers behind every digital pin: count in binary on three lamps with one write to PORTB, turn on a pull-up through PORTD, and read a button straight out of PIND.
- Timers by handTimer 1 set up register by register: a prescaler, CTC mode and OCR1A for a match every 500 ms, the compare flag polled and cleared by hand, and no millis() anywhere.
- The vector table and interruptsThe 26 jumps at the start of flash, read out of the chip itself: a Timer 1 interrupt that blinks while loop() sleeps, an INT0 handler that counts presses, volatile, and reading shared data safely.
- Cycle-counted delays in a .S fileCount a loop in CPU cycles from the data sheet and measure it with Timer 1, then write the delay as a function in its own assembly file and call it from C++.
- Step 2 · 16 lessons · 12 h
Embedded on the Arduino Uno
Need the Arduino basics first? Start here.
One board, twenty pins and a C++ sketch. From a lamp you switch to a game you can play.
Every lesson in the course
Guides and tools on the same subject
Arduino Timer1 interrupt
Open itArduino Uno pinout
Open itEmbedded track
Arduino, ESP32, Raspberry Pi Pico and STM32: pins, timing, buses, motors, WiFi, registers and debugging, every lesson checked on a simulated board.
See the whole trackQuestions people ask
What is direct port manipulation?
Setting a pin by writing its port register, such as PORTB, instead of calling digitalWrite(). It is many times faster and can change several pins in the same instant.
Do I need assembly to use registers?
No. Most register work is plain C++. The course adds a little assembly at the end to show what the compiler produces and how to count cycles.
Does this apply to other chips?
The names change but the ideas carry over. Embedded on the STM32F411 uses the same ideas on an ARM chip.