Pointers Pre Finals PDF
Document Details
Uploaded by Deleted User
Tags
Summary
This document discusses microcontrollers, including microprocessors, memory (ROM and RAM), input/output, and system buses. It also covers different architectures like von Neumann and Harvard. Concepts like Arduino programming and its components are then introduced.
Full Transcript
Microcontroller are small, compact computers designed for individual use. They typically consist of a microprocessor, memory (RAM and storage), input/output interfaces, and sometimes integrated peripherals. Microprocessor is the central processing unit (CPU) of a microcomputer, responsible for ex...
Microcontroller are small, compact computers designed for individual use. They typically consist of a microprocessor, memory (RAM and storage), input/output interfaces, and sometimes integrated peripherals. Microprocessor is the central processing unit (CPU) of a microcomputer, responsible for executing instructions and managing data flow within the system. Basic Blocks of Microcomputers Central Processing Unit- executes all the instructions and performs arithmetic and logic operations on data Memory memory in microcomputers is a crucial component that affects performance, storage, and overall functionality. ROM- Read Only Memory retains its content when the power is turned off (non-volatile). It is typically used to store instructions and data that do not change RAM (Random Access Memory) does not retain its content when the power is turned off (volatile). It is used to store programs and data that are temporary and might change during the course of executing a program. Input and Output Input and output in microcomputers refer to the processes of receiving data from external sources and sending processed data to external destinations. Structure Basic Blocks of Microcomputers System Bus In a microcomputer system, the bus is a critical component that facilitates communication between different parts of the computer, such as the CPU, memory, and input/output devices. TYPES OF BUSES In the address bus, information transfer takes place in only one direction, from the microprocessor to the memory or I/O elements. In the data bus, data can flow in both directions, that is, to or from the CPU. The control bus consists of a number of signals that are used to synchronize the operation of the individual microcomputer elements. The control bus consists of a number of signals that are used to synchronize the operation of the individual microcomputer elements. In von Neumann architecture, a single memory system with the same address and data buses is used for accessing both programs and data. This means that programs and data cannot be accessed simultaneously. The Harvard Architecture uses separate program and data memory units along with separate buses for instructions and data. This means that these processors can execute instructions and access data simultaneously. To execute a program, the CPU repeats the following three (3) steps for completing each instruction: 1. Fetch: The CPU fetches (instruction read) the instruction from the program memory (external to the CPU) into the instruction register. 2. 2. Decode: The CPU decodes or translates the instruction using the control unit. The control unit inputs the contents of the instruction register and then decodes (translates) the instruction to determine the instruction type. 3. 3. Execute: The CPU executes the instruction using the control unit. To accomplish the task, the control unit generates a number of enable signals required by the instruction. Arduino is an open-source electronics platform based on easy-to-use hardware and software. It is a microcontroller board, a software/IDE (Integrated Development Environment), and a programming language. Arduino offers the following advantages: Inexpensive: Arduino boards are relatively inexpensive compared to other microcontroller platforms. Cross-platform: The Arduino IDE runs on Windows, Macintosh OSX, and Linux operating systems. Simple, clear programming environment: The Arduino IDE is easy-to-use for beginners, yet flexible enough for advanced users to take advantage of as well. Open source and extensible software: The Arduino software is published as open-source tools, available for extension by experienced programmers. Open source and extensible hardware: The plans of the Arduino boards are published under a Creative Commons license, so experienced circuit designers can make their own version of the module, extending it and improving it. The following are the basic Arduino boards: Arduino Uno has 14 digital input/output pins (of which 6 can be used as *PWM outputs), 6 analog inputs, a USB connection, and a power jack. Arduino Nano is a compact board similar to the UNO without a power jack. It works with a Mini-B USB cable instead of a standard one. Arduino Leonardo has 20 digital input/output pins (of which 7 can be used as PWM outputs and 12 as analog inputs), a micro-USB connection, and a power jack. Arduino Micro is the smallest board of the Arduino family similar to the Arduino Leonardo. Microcontrollers Programming enables the creation of smart, automated systems by instructing microcontrollers on how to interpret and respond to various signals and conditions. Arduino Programming Arduino programming involves writing code to control Arduino microcontrollers, which are small, versatile computers used in various electronics projects. The code is typically written in a simplified version of C/C++ and is uploaded to the Arduino board using the Arduino Integrated Development Environment (IDE). Arduino Programming are divided into Three main parts: 1. Structure 2. Functions 3. Variables 1. Structure of an Arduino program (or sketch) includes the basic framework that every program follows. It consists of two main functions: 2.Functions in Arduino are blocks of code that perform specific tasks. Arduino provides a variety of built- in functions (like digitalWrite(), analogRead(), and delay() ) as well as the ability to define custom functions. Functions help organize code, making it easier to read and reuse. The data types most commonly used in Arduino are as follows: String declarations in Arduino are used to create and manage text data. In Arduino, you can use the String class or character arrays to handle strings. The following are examples of string declarations in Arduino. String text1 = "This is a string."; String text2 = String("This is a string."); Array Declaration is to store collections of data of the same type. This is useful for managing multiple values efficiently. The following are examples of array declarations in Arduino: int a; int pins[] = {2, 4, 8, 3, 6}; int sensors = {2, 4, -8, 3, 2}; Constant is a fixed value that cannot be changed during the execution of a program. Constants are useful for defining values that you want to refer to multiple times without risking accidental modification. They can improve code readability and maintainability.