FabAcademy

Vigyan Ashram

Embedded Programming

This assignment is about writing down what I learned in Embedded Programming, like the basics such as architectures, memory, peripherals, word size, microcontroller families, packages, and doing a group project comparing performance and development workflows for different architectures, along with an individual assignment and group assignment.

Embedded System Programming

An embedded system is like a special-purpose computer made up of both hardware and software. It's built to do a specific job, either on its own or as part of a bigger system. These systems can be set up to be programmed for different tasks or have a fixed job. They're found in lots of things we use every day, like industrial machines, smartphones, cars, and even toys. Some embedded systems are super simple, with no fancy screens or buttons, while others have more complicated interfaces like touchscreens. These systems are expected to keep growing, with predictions saying they'll be worth a lot of money by 2025. Big companies like Apple and Intel make the chips used in these systems, and the growth is happening because more people are using things like AI and mobile devices that need powerful chips.
An embedded system is a computer system—a combination of a computer processor, computer memory, and input/output peripheral devices—that has a dedicated function within a larger mechanical or electronic system.It is embedded as part of a complete device often including electrical or electronic hardware and mechanical parts. Because an embedded system typically controls physical operations of the machine that it is embedded within, it often has real-time computing constraints. Embedded systems control many devices in common use.In 2009, it was estimated that ninety-eight percent of all microprocessors manufactured were used in embedded systems.Modern embedded systems are often based on microcontrollers (i.e. microprocessors with integrated memory and peripheral interfaces), but ordinary microprocessors (using external chips for memory and peripheral interface circuits) are also common, especially in more complex systems. In either case, the processor used may be types ranging from general purpose to those specialized in a certain class of computations, or even custom designed for the application at hand. A common standard class of dedicated processors is the digital signal processor (DSP).Since the embedded system is dedicated to specific tasks, design engineers can optimize it to reduce the size and cost of the product and increase its reliability and performance. Some embedded systems are mass-produced, benefiting from economies of scale. Embedded systems range in size from portable personal devices such as digital watches and MP3 players to bigger machines like home appliances, industrial assembly lines, robots, transport vehicles, traffic light controllers, and medical imaging systems. Often they constitute subsystems of other machines like avionics in aircraft and astrionics in spacecraft. Large installations like factories, pipelines and electrical grids rely on multiple embedded systems networked together. Generalized through software customization, embedded systems such as programmable logic controllers frequently comprise their functional units. Embedded systems range from those low in complexity, with a single microcontroller chip, to very high with multiple units, peripherals and networks, which may reside in equipment racks or across large geographical areas connected via long-distance communications lines. For more information click on link Here

Embedded Systems

Embedded Systems Classification

Embedded Systems Classification

Type Characteristics
Mobile Embedded Systems Small and portable systems, like digital cameras.
Networked Embedded Systems Connected to a network, interact with other systems, such as home security systems or point of sale (POS) systems.
Standalone Embedded Systems Operate independently and perform specialized tasks, like calculators or MP3 players.
Real-time Embedded Systems Provide outputs within defined time intervals, crucial for time-sensitive tasks like traffic control systems.

Embedded Systems Performance Requirements

Performance Level Microcontroller Type
Small-scale Embedded Systems Simple microcontrollers, typically 8-bit.
Medium-scale Embedded Systems Larger microcontrollers (16-32 bit) allowing multiple connections.
Sophisticated-scale Embedded Systems Complex algorithms, software, and hardware, often requiring configurable processors and programmable logic arrays.

Common Software Architectures for Embedded Systems

Architecture Type Description
Simple Control Loops Manage hardware and programming with subroutine calls.
Interrupt Controlled Systems Main and secondary loops where interruptions trigger tasks.
Cooperative Multitasking Simple control loop within an API.
Preemptive Multitasking/Multithreading Used with real-time operating systems (RTOS), featuring synchronization and task-switching strategies.

Embedded Systems Applications

Application Description
Telecommunications Telephone switches, cell phones, routers, network bridges
Consumer Electronics MP3 players, television sets, mobile phones, video game consoles, digital cameras, GPS receivers, printers
Household Appliances Microwave ovens, washing machines, dishwashers, HVAC systems, home automation devices
Transportation Aircraft avionics, spacecraft systems, electric motors, automotive safety systems
Medical Equipment Monitoring equipment, medical imaging devices (PET, SPECT, CT, MRI)
Aerospace and Defense Safety-critical systems, fire safety systems, security systems
Wireless Sensor Networking Motes, networked wireless sensors

Basic Structure of an Embedded System

Sensor System Components

Component Description
Sensor It measures the physical quantity and converts it to an electrical signal which can be read by an observer or by any electronic instrument like an A2D converter. A sensor stores the measured quantity to the memory.
A-D Converter An analog-to-digital converter converts the analog signal sent by the sensor into a digital signal.
Processor & ASICs Processors process the data to measure the output and store it to the memory.
D-A Converter A digital-to-analog converter converts the digital data fed by the processor to analog data.
Actuator An actuator compares the output given by the D-A Converter to the actual (expected) output stored in it and stores the approved output.

For more info refer this site Click Here

Architecture


Von Neumann Architecture:

The Von Neumann architecture, named after the Hungarian-American mathematician and computer scientist John von Neumann, represents a fundamental design concept for modern computers. In this architecture, both instructions and data are stored in the same memory space, and a single bus is used to transfer both instructions and data between the CPU and memory.
In a Von Neumann architecture, the CPU performs operations sequentially, meaning it can only execute one instruction at a time. This limitation arises because the CPU shares a common bus for fetching instructions from memory and accessing data. As a result, if the CPU is fetching an instruction from memory, it cannot simultaneously perform a data operation, such as reading or writing data.


Harvard Architecture:

In a typical computer using Von Neumann architecture, instructions and data are stored together in the same memory. This means that the same pathways, called buses, are used to fetch both instructions and data. Because of this setup, the CPU can't perform both tasks simultaneously—reading instructions and accessing or modifying data—at the same time.
To address this limitation, Harvard Architecture was developed. In Harvard Architecture, there are separate storage areas and pathways (buses) for instructions and data. This means that the CPU can access instructions and read or write data at the same time without any conflict or slowdown. This separation of pathways helps overcome the bottleneck that exists in von Neumann's Architecture, where the CPU has to wait for one operation to finish before it can start another.
So, the main advantage of Harvard Architecture is that it allows the CPU to perform multiple tasks concurrently, leading to potentially faster and more efficient operation.For more information Click Here


Difference Between Von Neumann and Harvard Architecture

RISC AND CISC

Microprocessor


A Microprocessor is an important part of a computer architecture without which you will not be able to perform anything on your computer. A microprocessor is like the brain of a computer. It's a tiny chip that follows instructions to do math and logic tasks, producing outcomes. It fetches instructions, figures out what they mean, does what they say, and gives results. Basically, it's what makes your computer work.

Basics of Microprocessor
A Microprocessor takes a bunch of instructions in machine language and executes them, telling the processor what it has to do. Microprocessor performs three basic things while executing the instruction:
It performs some basic operations like addition, subtraction, multiplication, division, and some logical operations using its Arithmetic and Logical Unit (ALU). New Microprocessors also perform operations on floating-point numbers also.
Data in microprocessors can move from one location to another.
It has a Program Counter (PC) register that stores the address of the next instruction based on the value of the PC, Microprocessor jumps from one location to another and takes decisions.
A regular microprocessor structure looks like this.

Types of Microprocessor
A microprocessor is a computer processor that is found in most modern personal computers, smartphones, and other electronic devices. It is a central processing unit (CPU) that performs most of the processing tasks in a computer system. The microprocessor is a key component of a computer, as it controls the fetching, decoding, and execution of instructions that are stored in memory. You can say that microprocessor is used as the brain of the computing devices which control overall execution and operations. The development of microprocessors has played a significant role in the evolution of computers and has made it possible for them to become smaller, faster, and more powerful over time.

Processor Types

Types of Processors

Processor Type Description
Vector Processor A type of CPU designed to perform mathematical operations on arrays of data more efficiently than scalar processors.
Array Processor or SIMD Processor Designed for vector computations; employs multiple processing elements to operate in parallel.
Scalar Processor Executes scalar data, can be simple or powerful depending on capabilities.
RISC and CISC Processor Two approaches to CPU design - RISC has a smaller, simpler instruction set while CISC has a larger and more complex one.
Digital Signal Processor Specialized microprocessor for high-speed mathematical operations on digital signals.
Symbolic Processor Designed for symbolic computation, manipulation of mathematical expressions using symbolic logic.
Graphics Processor Specialized microprocessor for accelerating rendering of 2D and 3D graphics.

For more information Click Here

Microcontroller

A microcontroller (MCU) is a small computer on a single integrated circuit that is designed to control specific tasks within electronic systems. It combines the functions of a central processing unit (CPU), memory, and input/output interfaces, all on a single chip. Microcontrollers are widely used in embedded systems, such as home appliances, automotive systems, medical devices, and industrial control systems. They are also used in consumer electronics products, such as gaming systems, digital cameras, and audio players.

What is a microcontroller?
It's a small computer on a single chip.
It does tasks like processing, memory, and controlling other parts of a device.
It's commonly used in many things, from home appliances to gaming consoles.

What's inside a microcontroller?
It has a processor core for doing tasks.
Memory for storing data and instructions.
Input/output parts to interact with the world outside.
Communication interfaces to talk to other devices.


How are microcontrollers programmed?
They're customizable, meaning you can make them do specific tasks.
People use programming languages like C, C++, and assembly language to write code for them.

Difference Between Microprocessor And Microcontroller

Memory


Embedded memory is like a mini-storage space inside a computer chip. It holds important stuff like instructions and data that the chip needs to work with. This memory can either be part of the chip itself, like in a microcontroller, or it can be a separate piece connected to the chip. It stores data temporarily while the chip is running and keeps instructions for the chip to follow. There are different types of embedded memory like ROM, RAM, and Flash Memory, each serving different purposes in making the chip work smoothly.

Importance Of Memory
Embedded memory is really important for electronic devices. It's like the device's brain, storing all kinds of important stuff. In things like phones, tablets, and smartwatches, it keeps the operating system, apps, and your files safe.

In automotive systems, also need embedded memory. It stores the car's software, like how the engine works, and keeps track of data from sensors. In factories and other big machines, embedded memory is used to store instructions and data for controlling things and keeping an eye on what's happening.

Embedded memory needs to work well to keep everything running smoothly. It helps devices and systems work fast by quickly getting the info they need. This makes sure everything responds quickly and works without any hiccups.

Different Types Of Memories
Memory devices can be put into two big groups:
Primary Memory
Primary memory is the stuff your device uses actively while it's on. It's like your brain's working memory.

Secondary Memory
Secondary memory is like your long-term memory, where you store things for later but don't actively think about all the time.

Now, within those categories, we have two types of memories based on what happens when you turn off the power:

Non-volatile memory:
This memory keeps its data even when you turn off the power. It's like writing something down on paper; it stays there until you intentionally erase it.

Volatile memory:
This memory loses its data when you turn off the power. It's like writing something in sand; it's there while you're actively holding onto it, but once you let go, it's gone.I have refer this link for information for more Refer Link Click Here

The picture below illustrates the classification of embedded memory.

Primary Memory in Embedded Systems

Primary memory is the main memory in a computer that the processor directly uses. It's like the computer's short-term memory, holding onto data and instructions that are actively being used. There are two main types: RAM and ROM. RAM, or Random Access Memory, is where the computer stores data and instructions temporarily while it's running. It's fast but volatile, meaning it loses its contents when the power is turned off. ROM, or Read-Only Memory, contains instructions that never change. It's used to store essential programs that the computer needs to start up, like the BIOS. Unlike RAM, ROM is non-volatile, meaning it retains its data even when the power is off.

RAM
Type Description Applications
SRAM Uses flip-flops for storage, faster access times, used as cache memory Cache memory in high-speed processors
NVRAM Retains data without power, used in automotive systems, initial processor instructions System firmware storage, calibration constants, passwords
DRAM Volatile memory, high density, lower cost, requires refreshing, used as main memory Main memory in electronic devices
SDRAM Operates with synchronous interface, higher data transfer rates, multiple memory operations Embedded systems, faster data transfer rates
ROM
Type Description Applications
MROM Mask ROM, programmed during manufacturing, cost-effective for large-scale production Firmware storage
PROM Programmable ROM, one-time programmable, requires ROM burner Firmware, low-level programs
EPROM Erasable PROM, retains data after power cycle, erased by UV light Updates to stored data
EEPROM Electrically erasable PROM, can be selectively erased and re-programmed electronically Frequent data modifications, in-circuit re-programming
Flash Memory Electrically erasable and programmable ROM, block/sector erase and re-programming Firmware storage, system booting, data storage
Secondary Memory in Embedded Systems

Secondary memory, also known as secondary storage or auxiliary storage, refers to storage devices in a computer system used for data storage. Unlike primary memory, they are not directly interfaced with the Microprocessor unit and can retain data without continuous power. These devices, typically non-volatile, offer higher storage capacities at lower costs compared to primary memory. Common examples include HDDs, SSDs, optical drives, magnetic tape, and external storage devices like USB drives or memory cards. Secondary memory is utilized for data backup, archival storage, file storage, and long-term data retention, providing a means to store and retrieve large volumes of data even when the system is powered off.

Device Description Applications
Hard Disk Drives (HDDs) Non-volatile storage, large storage capacity, relatively low cost Data backup, file storage
Solid-State Drives (SSDs) Non-volatile storage, faster access times than HDDs Data storage, system booting
Optical Drives (CD/DVD/Blu-ray) Read-only or read-write optical storage Data storage, media playback
Magnetic Tape Sequential access storage, used for data backup and archival storage Data backup, archival storage
External Storage Devices (USB drives, memory cards) Portable storage, plug-and-play connectivity Data transfer, file storage

Memory Components in Embedded Systems

Type Description Characteristics Applications
RAM (Random Access Memory) SRAM (Static RAM) Fast access times, no refreshing required Cache memory in high-speed processors
DRAM (Dynamic RAM) Higher density, lower costs, requires refreshing Main memory in embedded systems
NVRAM (Non-volatile Random Access Memory) Various technologies retaining data without power Storing critical system information like firmware BBRAM, EEPROM, FeRAM, MRAM, PCM
ROM (Read-Only Memory) Mask ROM Data programmed during manufacturing Essential firmware storage
PROM (Programmable ROM) Programmable once after manufacturing Early firmware prototypes
EPROM (Erasable Programmable ROM) Erasable and reprogrammable with specialized equipment Software development and testing
EEPROM (Electrically Erasable Programmable ROM) Erasable and reprogrammable electrically Embedded system configuration and updates
Flash Memory Reprogrammable, multiple write cycles USB flash drives, SSDs, firmware updates

Applications of Embedded Memory

Application Examples
Consumer electronics Smartphones, tablets, digital cameras, gaming consoles, smart TVs.
Automotive industry Infotainment systems, engine control units, ADAS, vehicle diagnostics.
Internet of Things (IoT) devices Smart home devices, wearables, industrial sensors, connected appliances.
Medical devices Implantable devices, patient monitoring systems, medical imaging equipment.
Aerospace and defense systems Avionics systems, radar systems, UAVs, communication systems.
Resister

Registers are used in the CPU to store information on temporarily basis which could be data to be processed, or an address pointing to the data which is to be fetched. In 8051, there is one data type is of 8-bits, from the MSB (most significant bit) D7 to the LSB (least significant bit) D0. With 8-bit data type, any data type larger than 8-bits must be broken into 8-bit chunks before it is processed. The most widely used registers of the 8051 are A (accumulator), B, R0-R7, DPTR (data pointer), and PC (program counter). All these registers are of 8-bits, except DPTR and PC. To read more about resister refer link Click Here

In the 8051 microcontroller, various registers are used to store information temporarily:

Accumulator (A):

It holds data for arithmetic and logic operations. It's an 8-bit register ranging from D7 (most significant bit) to D0 (least significant bit).

R Registers (R0-R7):

These are general-purpose registers, each 8 bits wide. They are used for storing data during computations or for temporary storage.

B Register:

Similar to the accumulator, the B register is an 8-bit register utilized for arithmetic and logic operations. It's often used for multiplication and division operations.

Data Pointer (DPTR):

DPTR is a 16-bit register used for addressing data in external memory. It consists of two 8-bit registers, DPTRH and DPTRL, forming a 16-bit address.

Program Counter (PC):

The PC register keeps track of the memory address of the next instruction to be executed. It's a 16-bit register since it needs to address the entire program memory.

Stack Pointer (SP):

The SP register points to the top of the stack, used for storing return addresses and local variables during subroutine calls. It's also a 16-bit register.

These registers play crucial roles in executing programs efficiently on the 8051 microcontroller, handling data, addressing memory, and managing program flow.

Fuse

Fuses are essential electronic components safeguarding circuits by creating an open circuit if current draw exceeds safe limits. They are vital particularly in power supplies, ensuring protection at both system entry and individual power rails. Commonly, fuses prevent mishaps like shorting power rails to ground, averting potential damage to regulators or supplies. There are various types of fuses, including standard fuses, which feature a wire alloy that melts under excessive current, and resettable PTC fuses, which trip under heat from overcurrent, self-resetting after cooling. Additionally, circuit breakers, primarily used in AC power applications like homes, offer reusable protection with easy reset mechanisms. While each type has its advantages and disadvantages, they all contribute to maintaining circuit integrity and system safety.


In this week we have group assignment on :

Understanding the data sheets of microcontrollers
Studying the datasheet for the XIAO RP2040 Development Board is crucial for understanding its functionalities and specifications thoroughly. By downloading it from Google, you've ensured access to the latest information provided by the manufacturer. This document contains detailed technical information, such as electrical characteristics, pinout diagrams, communication protocols, and recommended operating conditions. With this knowledge, you can design, program, and troubleshoot projects effectively, leveraging the board's features to their full potential. The datasheet serves as a comprehensive reference guide, empowering you to make informed decisions regarding hardware connections, firmware development, and optimization strategies.

Compare the performance and development workflows for other architectures
Here we compare different microcontrollers with our selected RP2040 and assessed it alongside others based on key parameters: Microcontroller type, Core specifications, Architecture, Operating voltage, and Digital pin count. This evaluation helps us understand how the RP2040 stands out or fits within the broader landscape of microcontroller options.The details are in Grop Assignment.
Read More About Group Assignment

Individual Assignment

Then In Individal Assignment task is to write a program for a microcontroller development board that I made in previous assignment, to interact (with local input &/or output devices).Here I documented all steps for programming microcontroller board.


Ardino IDE

Step 1: First I have installed Aurdino ide and open in my system


Step 2: Then I click on Tools > Board > Boards Manager and search RP2040 and install


Step 3: From google i got doc find useful for installation Ardino board. I click link inside doc for for Xiao RP2040 refer doc for installation Link Here


Click Yes to install Xioa RP2040 board

Step 4: Then I click on Tools > Board > Boards Manager and search RP2040 and install


Step 5: Then, I connected microcontroller Xioa RP2040 board with my system with data cable and then selected port


Step 6: Write Program for my microcontroller board in C++. In which i want to blink light one by one delay time 1 second.


This is about my microcontroller and program i create....

Thonny

Step 1:First install Thonny from google


Step 2: Check for the installation by printing the "Hello word"


Step 3: Then I Added micropython firmware by Pressing the BOOTSEL button and hold it for second I connected the other end of the micro USB cable to my computer.


Step 4: Now, my thonny environment is ready for write program in python.then i started to learn about how the program we write in python here we should know about the pin connection for led to turn on.also we should have data cable in good working condition otherwise we get problem to connect.Here we have to import time and pins.


In above program all LED blink at same time. then I tried for another program in which one by one led will blink


Thonny Programming
Thonny Programming
Keylearning:

In this week we learn about how to read datasheet, about Pin connections,what is microcontroller,types of microcontroller,specification of chips, how to write program in different environment and in different languages.