Uploaded by Jameson Buhayang

Notes-for-Microprocessor

advertisement
Unit 1. Structural Components of Microprocessor/Microcontroller
Topics to be discussed are:
• Internal CPU Interconnection
• ALU
• CU
• Registers
• Other Peripherals
• Data Flow Diagram
Please refer on this file about the discussion:
Difference between Microprocessor and Microcontroller.pdf
Because we don’t have an actual microprocessor, microcontroller (Arduino UNO) was utilized.
For further discussion about Arduino kindly explore in reading the file Arduino Datasheet.pdf
*Arduino UNO R3
The Arduino UNO is the best board to get started with electronics and coding. If this is your first
experience tinkering with the platform, the UNO is the most robust board you can start playing with. The
UNO is the most used and documented board of the whole Arduino family.
Main Features
Arduino UNO is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins
(of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection,
a power jack, an ICSP header and a reset button. It contains everything needed to support the
microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter
or battery to get started. You can tinker with your UNO without worrying too much about doing
something wrong, worst-case scenario you can replace the chip for a few dollars and start over again.
* Arduino UNO Board Anatomy
Arduino boards senses the environment by receiving inputs from many sensors, and affects their
surroundings by controlling lights, motors, and other actuators. Arduino boards are the microcontroller
development platform that will be at the heart of your projects. When making something you will be
building the circuits and interfaces for interaction, and telling the microcontroller how to interface with
other components. Here the anatomy of Arduino UNO.
1. Digital Pins: Use these pins with digitalRead(), digitalWrite(), and analogWrite(). analogWrite()
works only on the pins with the PWM symbol.
2. Pin 13 LED: The only actuator built-in to your board. Besides being a handy target for your first
blink sketch, this LED is very useful for debugging.
3. Power LED: Indicates that your Arduino is receiving power. Useful for debugging.
4. ATmega Microcontroller: The heart of your board.
5. Analog In: Use these pins with analogRead().
6. GND and 5V Pins: Use these pins to provide +5V power and ground to your circuits.
7. Power Connector: This is how you power your Arduino when it's not plugged into a USB port
for power. Can accept voltages between 7-12V.
8. TX and RX LEDs: These LEDs indicate communication between your Arduino and your
computer. Expect them to flicker rapidly during sketch upload as well as during serial
communication. Useful for debugging.
9. USB Port: Used for powering your Arduino UNO, uploading your sketches to your Arduino, and
for communicating with your Arduino sketch (via Serial. println() etc.).
10. Reset Button: Resets the ATmega microcontroller.
Commented [JB1]: A built-in status indicator. this LED
often blinks or illuminates in a certain pattern briefly to
indicate that the board is functioning correctly and is
ready to execute your program. This can be helpful for
troubleshooting and verifying that your Arduino is
working as expected.
*Arduino Pinouts
*Arduino Programming Language
Visit this link to know more:
https://docs.arduino.cc/learn/
Arduino programming language, which is based on C/C++, is used for programming Arduino
microcontrollers. Arduino programming language can be divided in three main parts: functions, values
(variables and constants), and structure.
1. Functions:
Functions in Arduino programming are blocks of code that perform specific tasks. They are
essential for organizing your code and making it more modular and readable. There are two main
types of functions in Arduino:
a. Built-in Functions: Arduino provides a set of built-in functions that are part of the Arduino
core library. These functions are pre-defined and can be used to interact with the hardware and
perform common tasks, such as reading analog inputs, writing to digital pins, and managing
timers. Examples of built-in functions include digitalRead(), analogWrite(), and delay().
b. User-Defined Functions: You can also create your own functions to encapsulate custom
functionality. These functions allow you to break down your code into smaller, reusable blocks,
making it easier to manage and maintain. User-defined functions are defined with a return type
(if applicable), a name, and a set of parameters. For example:
2. Values (Variables and Constants):
Values in Arduino programming are used to store and manipulate data. There are two main
types of values:
a. Variables: Variables are used to store data that can change during the execution of the
program. They have a data type (e.g., int, float, char) and a name. You can assign values to
variables, perform calculations, and use them in control structures. For example:
b. Constants: Constants are used to store values that do not change during the program's
execution. They are declared with the const keyword and are often used for defining pin
numbers, mathematical constants, or other fixed values. For example:
3. Structure:
The structure of an Arduino program determines how the code is organized and executed.
Arduino programs have a specific structure that includes two main functions: setup() and loop().
a. setup() Function : This function is called once when the Arduino board is powered up or reset.
It is typically used for initializing variables, configuring pins, and setting up any hardware-related
settings. The setup() function runs only once at the beginning of the program.
b. loop() Function: The loop() function is where the main program logic resides. After the
setup() function is executed, the loop() function runs repeatedly in an infinite loop. This is
where you place the code that defines the behavior of your Arduino project.
By placing code in the setup() and loop() functions, you can control the flow and behavior of
your Arduino program.
Unit II. Fetch Decode Execute Cycle
The Arduino microcontroller, like many other microcontrollers, implements a simplified version
of the Fetch-Decode-Execute (FDE) cycle. The FDE cycle is a fundamental concept in computer
architecture that describes how a CPU (Central Processing Unit) executes instructions. While Arduino
microcontrollers are typically based on AVR or ARM architectures, I'll provide a simplified overview of
how this cycle is implemented in general:
1. Fetch: In the fetch stage, the CPU retrieves the next instruction from memory. In the
case of the Arduino, this typically involves fetching instructions from the program
memory (Flash memory). The program counter (PC) keeps track of the address of the
next instruction to be executed.
2. Decode: Once the instruction is fetched, it needs to be decoded to determine what
operation it represents. This involves breaking down the instruction into its opcode
(operation code) and any associated operands. The CPU identifies the instruction and
prepares to execute it.
3. Execute: In the execute stage, the CPU carries out the operation specified by the
instruction. This might involve performing arithmetic or logic operations, loading or
storing data, or branching to a different part of the program. The execution of an
instruction can takes multiple clock cycles.
Here's a more specific example of how this cycle works on an Arduino based on the AVR architecture:
•
The AVR microcontroller in the Arduino has a program counter (PC) that points to the
address of the next instruction to be fetched.
•
The AVR CPU fetches the instruction from Flash memory at the address specified by the
PC.
•
The fetched instruction is decoded to determine the operation to be performed.
•
The CPU executes the instruction. For example, if the instruction is an addition
operation, it will add two values from registers and store the result back in a register.
•
After execution, the PC is typically incremented to point to the next instruction, and the
cycle repeats with the fetch of the next instruction.
It's important to note that Arduino programs are typically written in C or C++, and the Arduino IDE
abstracts much of the low-level details of the microcontroller, making it more accessible for beginners.
However, the underlying hardware still follows the FDE cycle to execute instructions.
Keep in mind that different microcontroller architectures may have variations in their implementation
of the FDE cycle, but the basic concept remains the same.
Commented [JB2]: AVR is an acronym that stands for
"Alf and Vegard's RISC processor," named after the
Norwegian developers Alf-Egil Bogen and Vegard
Wollan. They created the AVR microcontroller
architecture while working at the Norwegian company
Atmel (now part of Microchip Technology). The AVR
architecture is a popular and widely used 8-bit
microcontroller architecture known for its simplicity,
efficiency, and ease of use, making it a common choice
for many embedded systems and hobbyist projects,
including various Arduino boards.
Unit III. Functional Operations of Microprocessors/Microcontroller
Topics to be discussed are:
• Data Movement
• Data Processing
• Data Storage
The Arduino microcontroller, like other microcontrollers, implements the fundamental operations of
Data Movement, Data Processing, and Data Storage to perform various tasks and functions. Here's how
Arduino accomplishes these operations:
1. Data Movement:
- GPIO (General-Purpose Input/Output): Arduino microcontrollers have digital and analog
pins that can be configured as either inputs or outputs. Data movement is achieved by reading
data from digital or analog input pins or writing data to digital output pins. For example, you can
read sensor values from an input pin or send signals to control LEDs or motors through output
pins.
- Serial Communication: Arduino boards often have built-in UART (Universal Asynchronous
Receiver/Transmitter) interfaces or support for other serial communication protocols like SPI
(Serial Peripheral Interface) and I2C (Inter-Integrated Circuit). These interfaces allow data to be
moved between the microcontroller and external devices, such as sensors, displays, or other
microcontrollers.
- Wireless Communication: Some Arduino boards come with wireless communication
capabilities (e.g., Wi-Fi, Bluetooth). These boards can transmit and receive data wirelessly,
enabling remote data movement between devices or over the internet.
2. Data Processing:
- Central Processing Unit (CPU): The CPU in the Arduino microcontroller executes instructions
that perform data processing tasks. These instructions can include arithmetic operations
(addition, subtraction, etc.), logic operations (AND, OR, etc.), and control flow operations
(conditional statements, loops, etc.). Data processing instructions are part of the program written
in the Arduino IDE.
- Libraries and Functions: Arduino provides a rich set of libraries and functions that simplify
data processing tasks. For example, you can use math functions to perform calculations,
manipulate strings, or process sensor data using predefined functions.
3. Data Storage:
- Registers and Memory: Arduino microcontrollers have a limited amount of registers and
memory for data storage. These registers are used for temporary storage of data during
calculations and operations. The Flash memory is typically used for program storage, while SRAM
is used for data storage during program execution.
- External Storage: Some Arduino boards support external storage options like microSD cards
or external EEPROM (Electrically Erasable Programmable Read-Only Memory). These can be
used for long-term data storage, such as logging sensor data or saving configuration settings.
- EEPROM: Many Arduino boards have a small amount of EEPROM memory (Electrically
Erasable Programmable Read-Only Memory) that can be used for non-volatile data storage. This
is often used to store configuration parameters or user settings that need to persist even when
the power is removed.
In summary, Arduino microcontrollers provide the necessary hardware interfaces, CPU,
memory, and libraries to implement Data Movement, Data Processing, and Data Storage for a
wide range of embedded and IoT applications. Programmers can write code in the Arduino IDE
using a simplified and user-friendly programming environment to interact with these features
effectively.
Download