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.

Group Assignment


Understanding the data sheets of microcontrollers

Studying the datasheet for the XIAO RP2040 Development Board for understanding its functionalities and specifications thoroughly. This document contains detailed technical information, such as electrical characteristics, pinout diagrams, communication protocols, and recommended operating conditions. With this knowledge, we can design, program, and troubleshoot projects effectively. The datasheet guides us 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 to understand how the RP2040 stands out or fits within the broader landscape of microcontroller options.The details are in Grop Assignment. Please find group assignment link Click Here

Individual Assignment

write a program for a microcontroller development board.

Embedded System Programming

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. 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


img from google


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 we will not be able to perform anything on our 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.


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). 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.

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 is 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.


Microcontrollers use programming language?

we 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 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.

Different Types Of Memories

Primary Memory

Primary memory is the stuff your device uses actively while it's on. It's like brain's working memory.

Secondary Memory

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

Again, Two types of memories based on what happens when we turn off the power:

Non-volatile memory

This memory keeps its data even when turn off the power and stays there until you intentionally erase it.

Volatile memory

This memory loses its data when turn off the power. It is there while we are actively holding onto it, but once we let go, it's gone. For more information 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. 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.

Fuse

An electrical fuse is a safety device that operates to provide protection against the overflow of current in an electrical circuit. An important component of an electrical fuse is a metal wire or strip that melts when excess current flows through it. It helps to protect the device by stopping or interrupting the current. Different types of fuses are shown in below diagram from google. for more information Read article


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.