- •1 Microcontroller Basics
- •1.1 Introduction
- •1.2 Frequently Used Terms
- •1.3 Notation
- •1.4 Exercises
- •2 Microcontroller Components
- •2.1 Processor Core
- •2.1.1 Architecture
- •2.1.2 Instruction Set
- •2.1.3 Exercises
- •2.2 Memory
- •2.2.1 Volatile Memory
- •2.2.3 Accessing Memory
- •2.2.4 Exercises
- •2.3 Digital I/O
- •2.3.1 Digital Input
- •2.3.2 Digital Output
- •2.3.3 Exercises
- •2.4 Analog I/O
- •2.4.1 Digital/Analog Conversion
- •2.4.2 Analog Comparator
- •2.4.3 Analog/Digital Conversion
- •2.4.4 Exercises
- •2.5 Interrupts
- •2.5.1 Interrupt Control
- •2.5.2 Interrupt Handling
- •2.5.3 Interrupt Service Routine
- •2.5.4 Exercises
- •2.6 Timer
- •2.6.1 Counter
- •2.6.2 Input Capture
- •2.6.3 Output Compare
- •2.6.4 Pulse Width Modulation
- •2.6.5 Exercises
- •2.7 Other Features
- •2.7.1 Watchdog Timer
- •2.7.2 Power Consumption and Sleep
- •2.7.3 Reset
- •2.7.4 Exercises
- •3 Communication Interfaces
- •3.1 SCI (UART)
- •3.3.1 Data Transmission
- •3.3.2 Speed Control Through Slave
- •3.3.4 Extended Addresses
- •3.4 Exercises
- •Index
2.1. PROCESSOR CORE |
|
|
|
21 |
||
|
|
|
|
|
|
|
|
addressing mode |
example |
result |
|
|
|
|
immediate |
ADD R1, #5 |
R1 |
← R1 + 5 |
|
|
|
register |
ADD R1, R2 |
R1 |
← R1 + R2 |
|
|
|
direct |
ADD R1, 100 |
R1 |
← R1 + M[100] |
|
|
|
register indirect |
ADD R1, (R2) |
R1 |
← R1 + M[R2] |
|
|
|
post-increment |
ADD R1, (R2)+ |
R1 |
← R1 + M[R2] |
|
|
|
|
ADD R1, −(R2) |
R2 |
← R2 + d |
|
|
|
pre-decrement |
R2 |
← R2 − d |
|
||
|
|
|
R1 |
← R1 + M[R2] |
|
|
|
displacement |
ADD R1, 100(R2) |
R1 |
← R1 |
+ M[100 + R2] |
|
|
indexed |
ADD R1, (R2+R3) |
R1 |
← R1 |
+ M[R2+R3] |
|
|
memory indirect |
ADD R1, @(R2) |
R1 |
← R1 |
+ M[M[R2]] |
|
Table 2.2: Comparison of addressing modes.
2.1.3Exercises
Exercise 2.1.1 What are the advantages of the Harvard architecture in relation to the von Neumann architecture? If you equip a von Neumann machine with a dual-ported RAM (that is a RAM which allows two concurrent accesses), does this make it a Harvard machine, or is there still something missing?
Exercise 2.1.2 Why was RISC developed? Why can it be faster to do something with several instructions instead of just one?
Exercise 2.1.3 What are the advantages of general-purpose registers as opposed to dedicated registers? What are their disadvantages?
Exercise 2.1.4 In Section 2.1.2, we compared different address formats. In our example, the accumulator architecture requires the least instructions to execute the task. Does this mean that accumulator architectures are particularly code-efficient?
Exercise 2.1.5 What are the advantages and drawbacks of a load/store architecture?
Exercise 2.1.6 Assume that you want to access an array consisting of 10 words (a word has 16 bit) starting at memory address 100. Write an assembler program that iterates through the array (pseudocode). Compare the addressing modes register indirect, displacement, auto-increment, and indexed.
Exercise 2.1.7 Why do negative numbers in an arithmetic shift left (ASL) stay negative as long as there is no overflow, even though the sign bit is not treated any special? Can you prove that the sign bit remains set in an ASL as long as there is no overflow? Is it always true that even with an overflow the result will remain correct (modulo the range)?