Revised Body
Revised Body
23KD5A0213
INTRODUCTION
Functional requirements
Embedded systems can be categorized based on their functional requirements, such as:
Real-time: These systems are required to produce output within a specified timeinterval.
They are often used in medical, military, and industrial sectors.
Standalone: These systems can perform tasks without a host system or externalprocessing
resources. Examples include digital watches, cameras, and MP3 players.
Mobile: These systems are small and portable, such as smartphones and laptops.
Microcontroller performance
Embedded systems can also be categorized based on the microcontroller's performance. These
include:
Small-scale: These systems are designed with an 8-bit or 16-bit microcontroller andcan be
powered by a battery.
Medium-scale: These systems are designed with a 16-bit or 32-bit microcontroller andare faster
than small-scale systems.
Complex: These systems are designed with a 32-bit or 64-bit microcontroller and areused to
perform more complex functions
1
Roll No. 23KD5A0213
The heart of a Microchip embedded system is a microcontroller, most commonly from their PIC
(Peripheral Interface Controller) or dsPIC (Digital Signal Processor PIC) families, offering different
levels of processing power and features depending on the application.
Peripherals on-chip:
Applications:
Microchip offers a diverse selection of microcontrollers with varying processing power, memory
size,and peripheral capabilities, allowing developers to choose the optimal chip for their needs.
Ease of development:
The MPLAB IDE and supporting libraries provide a user-friendly development environment.
Reliable performance:
Microchip microcontrollers are known for their stability and reliability in demanding environments.
2
Roll No. 23KD5A0213
8 Bit Microcontrollers
Microcontroller
3
Roll No. 23KD5A0213
(4) Fire detection and safety devices such as home security systems.
PIC Microcontroller
PIC stands for Programmable Interface Controllers. It was developed by a Microchip average.
It is fast and simple to implement program when we compare with other microcontrollers like 8051.
Theease of programming and simple to interfacing with other peripherals PIC become successful
microcontroller.
AVR Microcontroller
AVR microcontroller was developed in the year of 1996 by Atmel Corporation. The structural
designof AVR was developed by the Alf-Egil Bogen and Vegard Wollan. It is commonly accepted that
AVRstands for Alf and Vegard’s RISC microcontroller, which is also known as Advanced Virtual
RISC.
The AT90S8515 was the initial microcontroller which was based on the AVR architecture, though the
first microcontroller to hit the commercial market was AT90S1200 in the year 1997.
ARM Processor
Advanced RISC Machine (ARM) this microcontroller was introduced by Acron Computer
Organization. It is manufactured by Apple, Qualcomm, Motorola, etc. The Processor of the ARM
microcontroller belongs to the family of CPUs which are based on Reduced Instruction Set
Computer (RISC) and also ARM Microprocessor. An ARM makes at 32-bit and 64-bit RISC multi-
core processors. The speed of the ARM microcontroller is 1 clock cycle per machine cycle and the
power consumption is low.
4
Roll No. 23KD5A0213
MPLAB X IDE supports a wide range of Microchip's 8-bit, 16-bit, and 32-bit
microcontrollers. It also supports third-party software and hardware development tools.
Technology.[1][2][3][4][5][6][7][8]
MPLAB Extensions for Visual Studio Code and MPLAB X for NetBeans platform are
the latesteditions of MPLAB.[9][10][11] MPLAB and MPLAB X support project management,
code editing,debugging and programming of Microchip 8-bit PIC and AVR (including
ATMEGA) microcontrollers, 16-bit PIC24 and dsPIC microcontrollers, as well as 32-bit SAM
(ARM) and PIC32 (MIPS) microcontrollers.
MPLAB is designed to work with MPLAB-certified devices such as the MPLAB ICD
3 and MPLAB REAL ICE, for programming and debugging PIC microcontrollers using a personal
computer. PICKit programmers are also supported by MPLAB.
6
Roll No. 23KD5A0213
MPLAB X supports automatic code generation with the MPLAB Code Configurator and the
MPLAB Harmony Configurator plugins.
2. Compile, assemble and link the software using the assembler and/or compiler and linker to
convert your code into “ones and zeros” – machine code for the MCUs. This machine code will
eventually become the firmware (the code programmed into the microcontroller).
3. Test your code. Usually a complex program does not work exactly the way imagined, and “bugs”
need to be removed from the design to get proper results. The debugger allows you to see the “ones
and zeros” execute, related to the source code you wrote, with the symbols and function names from
your program. Debugging allows you to experiment with your code to see the value of variables at
various points in the program, and to do “what if” checks, changing variable values and stepping
through routines.
4. “Burn” the code into a microcontroller and verify that it executes correctly in the finished
application. Of course, each of these steps can be quite complex. The important thing is to
concentrate on the details of your own design, while relying upon MPLAB X IDE and its
components to get through each step without continuously encountering new learning curves.
7
Roll No. 23KD5A0213
In 1980, Intel developed the first Microcontroller (8051) with Harvard Architecture 8051
andsince then Microcontrollers brought a revolution in Electronics and embedded industry.
And with the technological advancement over the time, now we have many more efficient and
lowpower microcontrollers like AVR, PIC, ARM. These Microcontrollers are more capable
andeasy to use, having the latest communication protocols like USB, I2C, SPI, CAN
etc. Even Arduino and Raspberry Pi have completely changed the perspective towards
Microcontrollers, and Raspberry Pi is not just a microcontroller but it has whole computer
inside
Writing Your First Program with PIC Microcontroller and Setting up Configuration Bit
Creating a New Project using MPLAB-X:
Step 1: Launch the MPLAB-X IDE that we installed in the previous class, once loaded it
should look something like this.
Step 2: Click on Files -> New Project, or use the hotkey Ctrl+Shift+N. You will get the
following POP-UP, from which you have to select Standalone Project and click Next.
Step 3: Now we have to select our Device for the project. So type as PIC16F877A over
the Select Device dropdown section. Once done it should be like this and then Click on Next.
8
Roll No. 23KD5A0213
Step 4: The next page will allow us to select the tool for our project. This would be PicKit 3
for our project. Select PicKit 3 and click on next
Step 5: Next page will ask to select the compiler, select the XC8 Compiler and click next.
Step 6: In this page we have to name our project and select the location where the project has
to be saved. I have named this Project as Blink and saved it on my desktop. You can name and
save it in your preferable way. Our project will be saved as a folder with the Extension .X,
which can be directly launched by MAPLB-X. Click Finish once done.
9
Roll No. 23KD5A0213
Step 7: That's it!!! Our project has been created. The left most window will show the project
name (Here Blink), click on it so that we can view all the directories inside it.
In order to start programming we need to add a C Main file, inside our Source file directory.
To do this simply right click on the source file and select New -> C Main File, as shown in the
image below.
Step 8: The following dialog box will appear in which the name of the C-file has to be
mentioned. I have named in Blink again, but the choice is left to you. Name it in the File name
column and click on finish.
Step 9: Once the C main File is created, the IDE will open it for us with some default codes
in it, as shown below.
Step 10: That's it now we can start programming our code in the C-main File. The default
code will not be used in our tutorials. So let's delete them completely.
10
Roll No. 23KD5A0213
Variable arrays:
• An array is a set of data, stored in consecutive memory locations, beginning at a named
address–
Declare array name and number of data elements, N– Elements are “indexed”, with indices
[0 ... N-1]
C control structures:
• Control order in which instructions are executed (program flow)
• Conditional execution
– Execute a set of statements if some condition is met – Select one set of statements to be
executed from several options, depending on one or more conditions
• Iterative execution
– Repeated execution of a set of statements
• A specified number of times, or
• Until some condition is met, or
• While some condition is true
C functions:
• A function is “called” by another program to perform a task
– The function may return a result to the caller
– One or more arguments may be passed to the function/procedure
Pointers:
• Objectives:
In this chapter the basic concepts of pointers are explained.
At the end of this chapter, one should be able to:
- declare and initialize a pointer
- use pointers and pointer operators
- understand the close relationship between pointers and arrays
- use pointers to pass arguments by reference to a function - use pointers to functions
12
Roll No. 23KD5A0213
Declaration
Like every variable in C, a pointer variable must be declared before it can be used. In
itsmost general form, a pointer declaration can be written as:
<target datatype> * <name>;
The * in the declaration indicates that the variable is a pointer. For instance, int *ptr;
declares the pointer variable with name ptr that can point to a variable of the type int.
13
Roll No. 23KD5A0213
Advanced C Programming
Union in C:
Union is a user defined datatype that allows storage of heterogeneous elements in
the same memory location. Size of the union is the size of the largest element in the
union.Below is the picturesque representation of a union.
Pointer review:
Pointers are symbolic representation of addresses. They enable programs to simulate
call-by- reference as well as to create and manipulate dynamic data structures. It’s general
declaration in C/C++ has the format:
Syntax:
14
Roll No. 23KD5A0213
Array of Pointers in C:
In C, a pointer array is a homogeneous collection of indexed pointer variables that are
references to a memory location. It is generally used in C Programming when we want to
point at multiple memory locations of a similar data type in our C program. We can access
the data by dereferencing the pointer pointing to it.
Syntax: pointer type *array name [array size]; Here, pointer type: Type of data the
pointer is pointing to. array name: Name of the array of pointers.
array size: Size of the array of pointers.
Function Pointer in C:
In C, like normal data pointers (int *, char *, etc.), we can have pointers to functions.
Following is a simple example that shows declaration and function call using function
pointer.
#include <stdio.h>
// A normal function with an int parameter
// and void return type void fun (int a)
{ printf ("Value of a is %d\n", a); }
int main ()
{
// fun_ptr is a pointer to function fun() void (*fun_ptr)(int) = &fun;
/* The above line is equivalent of following two void (*fun_ptr) (int); fun_ptr =
&fun; */
// Invoking fun() using fun_ptr (*fun_ptr)
(10); return 0;
}
Output:
Value of a is 10
15
Roll No. 23KD5A0213
16
Roll No. 23KD5A0213
1. It allocates the memory dynamically. All the nodes of linked list are non-contiguously stored
in the memory and linked together with the help of pointers.
2. Sizing is no longer a problem since we do not need to define its size at the time of
declaration. List grows as per the program's demand and limited to the available memory
space.
Singly linked list or One way chain
Singly linked list can be defined as the collection of ordered set of elements. The number of
elementsmay vary according to need of the program. A node in the singly linked list consist of two
parts: datapart and link part. Data part of the node stores actual information that is to be represented
by the node while the link part of the node stores the address of its immediate successor.
One way chain or singly linked list can be traversed only in one direction. In other words, we
can saythat each node contains only next pointer, therefore we can not traverse the list in the reverse
direction.
Consider an example where the marks obtained by the student in three subjects are stored in a
linkedlist as shown in the figure.
In the above figure, the arrow represents the links. The data part of every node contains the marks
obtained by the student in the different subject. The last node in the list is identified by the null
pointer which is present in the address part of the last node. We can have as many elements we
require, in the data part of the list.
Callback in C:
A callback is any executable code that is passed as an argument to another code, which
is expected to call back (execute) the argument at a given time. In simple language, If a reference
of a function is passed to another function as an argument to call it, then it will be called a
Callback function.
17
Roll No. 23KD5A0213
Interrupt Handling:
Understand how to handle interrupts effectively. Keep interrupt service routines (ISRs)
as short and fast as possible, avoiding complex operations and lengthy code execution
withinthem.
Low-Power Modes:
Learn how to use low-power modes and sleep modes effectively to conserve energy in
battery- powered embedded systems. This is crucial for extending the battery life of
devices.
Tricks:
Bit Manipulation: Master bitwise operations for tasks like setting, clearing, or toggling
specific bits in registers. This is often necessary for configuring hardware peripherals
and optimizing memory usage.
Inline Assembly: In some cases, inline assembly code can be used to optimize critical
sections of your code, especially when dealing with hardware-specific operations.
18
Roll No. 23KD5A0213
Optimized Algorithms: Explore algorithms that are tailored for embedded systems, such
as fixed-point arithmetic for platforms without a floating-point unit or optimized data
structures for specific use cases.
Cautions:
Testing and Validation: Rigorously test your code, especially in real-world conditions that
mimic the actual environment in which your embedded system will operate. Consider edge
cases, fault tolerance, and error handling in your testing procedures.
19
Roll No. 23KD5A0213
Internet of things
Internet of things (IoT)
It describes devices with sensors, processing ability, software and other technologies that connect
and exchange data with other devices and systems over the Internet or other communication
networks.[1][2][3][4][5] The Internet of things encompasses electronics, communication, and computer
science engineering. "Internet of things" has been considered a misnomer because devices do not need
to be connected to the public internet; they only need to be connected to a network[6] and beindividually
addressable.[7][8]
The field has evolved due to the convergence of multiple technologies, including ubiquitous
computing, commodity sensors, and increasingly powerful embedded systems, as well as machine
learning.[9] Older fields of embedded systems, wireless sensor networks, control systems,
automation (including home and building automation), independently and collectively enable the
Internet of things.[10] In the consumer market, IoT technology is most synonymous with "smart home"
products, including devices and appliances (lighting fixtures, thermostats, home security systems,
cameras, and other home appliances) that support one or more common ecosystems and can be
controlled via devices associated with that ecosystem, suchas smartphones and smart
speakers. IoT is also used in healthcare systems.[11]
There are a number of concerns about the risks in the growth of IoT technologies and products,
especially in the areas of privacy and security, and consequently there have been industry and
government moves to address these concerns, including the development of international and local
standards, guidelines, and regulatory frameworks.[12] Because of their interconnected nature, IoT
devices are vulnerable to security breaches and privacy concerns. At the same time, the way these
devices communicate wirelessly creates regulatory ambiguities, complicating jurisdictional
boundaries of the data transfer.[13]
20
Roll No. 23KD5A0213
While the idea of IoT has been in existence for a long time, a collection of recent
advancesin a number of different technologies has made it practical.
Access to low-cost, low-power sensor technology. Affordable and reliable sensors
aremaking IoT technology possible for more manufacturers.
Connectivity: A host of network protocols for the internet has made it easy to connect
sensors to the cloud and to other “things” for efficient data transfer.
Machine learning and analytics. With advances in machine learning and analytics, along
with access to varied and vast amounts of data stored in the cloud, businesses can gather
insights faster and more easily. The emergence of these allied technologies continues to
push the boundaries of IoT and the data produced by IoT also feeds these technologies.
21
Roll No. 23KD5A0213
BLE only transmits data in one direction. Let’s take a look at a BLE beacon attempting
to communicate with a nearby smartphone. A Bluetooth beacon device periodically
broadcasts data packets. Nearby smartphones using specific apps or pre-installed services
can detect these data packets.
22
Roll No. 23KD5A0213
Given that BLE is currently used by billions of devices, it is crucial to examine its
securityflaws. While these personal and commercial gadgets enhance our lives and boost
productivity, they also make systems more vulnerable to attacks. The prevalence of BLE in
healthcare applications raises concerns about serious security and privacy issues. Once a
BLE connection is established, it is considered practically unbreakable.
23
Roll No. 23KD5A0213
However, BLE devices are still susceptible to eavesdropping, pin cracking, Man- In-
The- Middle (MITM) attacks, and other threats, particularly due to improper pairing,
unsuitable authentication, and poor protocol implementation (e.g., lack of adequate
encryption). Consequently, security flaws can lead to stolen personal data, unlocked smart
locks, misinterpreted messages, IoT devices running out of battery unexpectedly, and more.
Bluetooth LE security modes The Generic Access Protocol (GAP) for a BLE
connection specifies two security modes and several security levels for each mode.
There are four levels of security in Security Mode 1, which uses encryption to establish
security.
Security Level 1 – No Security (No Encryption and No Authentication)
Security Level 2 – Unauthenticated pairing with encryption
A communication network enables shared computing, where many users or terminals can
access the same computer system. In specific scenarios, shared computing can enable one
central system to handle the brunt of the work and distribute its results among multiple users
who lack that capability.
Communication networks are also used in decentralized computing, where many
computers can work together as peers. These networks help make it possible to transfer data
from one point to another. For instance, whatever device you use to read this webpage is
wirelessly connected to the All About Circuits server in some other part of the world. From
there, information is moved from the server to your device, allowing you to read this article.
An important point to note is that, for the different devices in the network to communicate or
share data effectively, they must speak a common language. This is where communication
protocols come into play.
24
Roll No. 23KD5A0213
An IoT Central application lets you monitor and manage millions of devices throughout
their life cycle. This guide is for device developers who implement the code to run on
devices that connect to IoT Central.
Devices interact with an IoT Central application by using the following primitives:
Telemetry is data that a device sends to IoT Central. For example, a stream of
temperaturevalues from an onboard sensor.
Properties are state values that a device reports to IoT Central. For example, the current
firmware version of the device. You can also have writable properties that IoT Central can
update on the device such as a target temperature. Commands are called from IoT Central
to control the behavior a device. For example, your IoT Central application might call a
command to reboot a device.
Types of devices:
The following sections describe the main types of devices you can connect to an IoT
Centralapplication:
• IoT device
An IoT device is a standalone device that connects directly to IoT Central. An IoT
device typically sends telemetry from its onboard or connected sensors to your IoT Central
application. Standalone devices can also report property values, receive writable property
values, and respond to commands.
• IoT Edge device
An IoT Edge device connects directly to IoT Central. An IoT Edge device can send its
own telemetry, report its properties, and respond to writable property updates and
commands. IoT Edge modules process data locally on the IoT Edge device. An IoT Edge
device can also act as an intermediary for other devices known as downstream devices.
Scenarios thatuse IoT Edge devices include:
25
Roll No. 23KD5A0213
Aggregate or filter telemetry before it's sent to IoT Central. This approach can help
reducethe costs of sending data to IoT Central.
Enable devices that can't connect directly to IoT Central to connect through the IoT
Edge device. For example, a downstream device might use Bluetooth to connect to the IoT
Edgedevice, which then connects over the internet to IoT Central.
Control downstream devices locally to avoid the latency associated with connecting to
IoTCentral over the internet.
IoT Central only sees the IoT Edge device, not the downstream devices connected to
the IoT Edge device.
Azure IoT Central is a ready-made UX and API surface for connecting and managing
devices at scale, delivering reliable data for business insights. It preassembles platform as a
service (PaaS) offering, bringing together each service beneath it for an easy-to-configure,
comprehensive, andsecure IoT offering.
26
Roll No. 23KD5A0213
CONCLUSION
Program Outcomes:
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
PSO1 PSO2
27