Embedded System (MBD)
Module 1 - Setup
Module 2 - Introduction to AVR Assembly
1. Introduction to AVR Assembly Language
Assembly is a low-level programming language that allows manipulation of every bit in memory, res...
2. ATmega328P Hardware & Memory Architecture
A. Memory Map The ATmega328P memory map provides information on how the Microcontroller Unit (MCU...
3. Input/Output (I/O) Programming
On the Arduino Uno (ATmega328P), digital I/O is controlled through Port B, Port C, and Port D. Ea...
4. Assembly Integration with Arduino IDE
To combine Assembly with Arduino C++ code, the extern "C" directive is used in the .ino file and ...
5. AVR Assembly Instruction Set
Operand Notation Before diving into the instructions, here are the common operand symbols used: ...
6. Status Register (SREG)
The Status Register contains flags that indicate the results of arithmetic/logic operations. This...
7. Delay Implementation Without Library
Delays can be created using nested loops that consume a certain number of clock cycles. Delay Cal...
8. Complete Program Examples
A. Blink LED #define __SFR_OFFSET 0x00 #include "avr/io.h" .global main main: SBI DDRB, 5 ...
Module 3 - Serial Port
Introduction to USART
1. USART Definition USART (Universal Synchronous/Asynchronous Receiver/Transmitter) is a communic...
USART Register Architecture of ATmega328p
The ATmega328p microcontroller uses several specific registers to control and monitor USART commu...
Implementation and Assembly Code Examples
This page contains basic implementation examples of USART serial communication using the Assembly...
Module 4 - Arithmetic
From memory access, addressing modes, the SREG, to arithmetic operations in AVR assembly,
1. Memory in AVR Architecture
AVR Architecture is an 8 bit single-chip RISC microcontroller with a modified Harvard Architectur...
2. Addressing Modes
Due to how the AVR Architecture and its memory are organized, AVR instructions, including arithme...
3. The Status Register
The Status Register (SREG) is a special 8 bit register that saves different operational status fl...
4. Advanced Arithmetic Operations
As a refresher, here are some fundamental AVR arithmetic and logical instructions. Mnemonic Op...
5. The Stack
The Stack is a memory section of the SRAM that follows First-In-First-Out (FIFO) principles. It i...
6. Printing Bytes as Hexadecimal Values
To easily debug and view numbers, we can create a subroutine that outputs numbers into serial. Si...
7. 𝔗𝔥𝔢 ℭ𝔬𝔡𝔢
#define __SFR_OFFSET 0x00 #include "avr/io.h" .global main main: RCALL SER_init LDI ZH, ...
8. References
“AVR ® Instruction Set Manual AVR ® Instruction Set Manual.” Available: https://ww1.microchip.com...
Module 5 - Timer
1. Introduction to AVR Timers
1.1. Overview The ATmega328P is a widely popular 8-bit microcontroller, serving as the "brain" fo...
2. Operating Modes
2.1. Normal Mode In Normal Mode, the timer acts as a simple up-counter. It starts from 0 and inc...
3. Timer0
3.1. TCNT0 (Timer/Counter 0 Register) The TCNT0 register is the core component of the 8-bit TIME...
4. Timer1
4.1. TCNT1 (Timer/Counter Register) TCNT1 is functionally the same as TCNT0, serving as the core...
5. Delay Using Timers
5.1. Delay Calculation in Normal Mode In Normal Mode, the timer always counts up to its maximum v...
6. Der Code
6.1. Code Example 1 (Timer0) This code toggles PD5 every 0.5s. The delay_timer0 subroutine uses ...
Module 6 - Interrupt
1. Introduction to Interrupt
An interrupt is a mechanism used in microcontroller programming to pause the execution of the cur...
2. Interrupt Handler
On the ATMega328P microcontroller, there are three essential requirements that must met to enable...
3. External Interrupt Registers
For detailed information about the registers, please refer to the Atmega32p datasheet. here Fro...
4. Internal/Timer Interrupts
Internal Interrupts Now Internal interrupts or Timer interrupts is somewhat more complex then ext...