You are on page 1of 37

Embedded Systems using STM32

Dr. Muhammad Irfan


Assistant Professor, FEE

Faculty of Electrical Engineering, GIK Institute


Intro

▶ PhD graduate from CityU Hong Kong

▶ Seven SCI Journals and many conference


papers
▪ Presented in UK, US, Singapore, HK, Shenzhen
▪ Reviewer in SCI Journals, e.g., IEEE TVLSI, IEEE
Access, IEEE TCAS II, etc
▪ Two Patent Applications filed in US

▶ Other than papers ☺


▪ Vice-Chair IEEE CityU HK Student Branch
▪ Resident Tutor at CityU Hong Kong

▶ I love Video Games and Photography.

1
Faculty of Electrical Engineering, GIK Institute
Education

University of Engineering and


Technology, Pakistan

▶ BS Electrical Engineering Bachelors


2009 2013
▪ Communication Degree

▶ MS Electrical Engineering Lahore University of Management


Teaching Sciences, Pakistan
▪ Embedded Systems
Master
2014 2016
▶ PhD Electrical Engineering Degree

▪ Reconfigurable Computing
City University of Hong Kong

Teaching
PhD
2021 2018
Degree

2
Faculty of Electrical Engineering, GIK Institute
Teaching Interests
◼ Microcontrollers / FPGAs
◼ Memory Design
◼ Digital Systems Design
◼ Internet of things
◼ Hardware programming / Embedded Systems
◼ Neural Networks implementation, AI Acceleration

4
Faculty of Electrical Engineering, GIK Institute
Communication
• WhatsApp group:
• Only me and CR will be able to send message in the group.
If you have any issues to discuss such as scheduling a
class, asking for notes, lecture timings, etc., consult CR, and
he will communicate to me accordingly.

• Email: m.irfan@ieee.org

• Office: F07 FEE


• Better to take appointment before visiting my office.

• Office Hours:
• Tuesday: 4-5pm

• Course Material:
• Google Classroom

• Questions:
• Raise Hand
• Ask end of Lecture

Faculty of Electrical Engineering, GIK Institute 5


Resources

• All lectures and other resources will be uploaded


on the Google Classroom

• I will try to upload the specific portion of the book


from where you will need to cover the topic.

Faculty of Electrical Engineering, GIK Institute 6


Topics
• Embedded Systems
• Microcontrollers vs. Microprocessors
• Most common microcontrollers
• STM32 family
• Discovery Board
• Cortex M4
• Development Tools

Faculty of Electrical Engineering, GIK Institute 7


Embedded Systems
Topics

Embedded systems (ES) = information processing systems


embedded into a larger product

•Examples
:

• Often, the main reason for buying is not information processing

Faculty of Electrical Engineering, GIK Institute


©
www.braingrid.org
© www.openpr.com

Faculty of Electrical Engineering, GIK Institute


Many Names – Similar Meanings

© Edward Lee

Faculty of Electrical Engineering, GIK Institute


General Purpose Microprocessors vs.
Microcontrollers
• General Purpose Microprocessors

General I/O Serial


Purpose RAM ROM Timer
Port Port
Micropro
cessor
(CPU) Buses

• Microcontrollers (MCUs)
Microcontroller

I/O Serial
RAM ROM Timer
Port Port
CPU
Fig. is Correct
Buses

Faculty of Electrical Engineering, GIK Institute 11


Most common microcontrollers
• 8-bit microcontrollers
– AVR
– PIC
– HCS12
– 8051

• 32-bit microcontrollers
– ARM
– AVR32
– PIC32

Faculty of Electrical Engineering, GIK Institute 12


Arm
• Arm does not produce chips but designs & sells
the license of its of architecture to others.
• More than 200 companies have bought the Arm
architecture and provide their Arm chips.

Faculty of Electrical Engineering, GIK Institute 13


ARM Naming

Faculty of Electrical Engineering, GIK Institute 14


Low to High end

Faculty of Electrical Engineering, GIK Institute 15


Development Board

Faculty of Electrical Engineering, GIK Institute 16


Development Board (Cont.)

Faculty of Electrical Engineering, GIK Institute 17


Development Board (Cont.)

Faculty of Electrical Engineering, GIK Institute 18


Development Board (Cont.)

Faculty of Electrical Engineering, GIK Institute 19


Development Board (Cont.)

Faculty of Electrical Engineering, GIK Institute 20


Development Board (Cont.)

Faculty of Electrical Engineering, GIK Institute 21


Development Tools

+ STM32CubeMX

Faculty of Electrical Engineering, GIK Institute 22


Development Tools

Faculty of Electrical Engineering, GIK Institute 23


Development Board (Cont.)

Faculty of Electrical Engineering, GIK Institute 24


Nucleo

Indicate
pin numbers

Faculty of Electrical Engineering, GIK Institute 25


STM32CubeIDE

Inherit features from


STM32CubeMX

Faculty of Electrical Engineering, GIK Institute 26


Languages
◼ High Level Languages
◼ Easy to develop and update
◼ C Language
◼ Acceptable performance
◼ Easy to develop and update High Level Languages
◼ Low Level Languages (like VB)
◼ High performance C Language
◼ Not portable
Machine Language

Faculty of Electrical Engineering, GIK Institute 27


A simple C program
◼ Write a program that calculate the sum of
{1,3,…,13,15}
#include <stm32f10x.h>
int main ()
{
unsigned int sum;

for (int i = 1; i <= 15; i+=2)


sum += i;

while (1);
return 0;
}

Faculty of Electrical Engineering, GIK Institute 28


Data Types

Data type Size Range


char 1 byte -128 to 127
unsigned char 1 byte 0 to 255
short int 2 bytes -32,768 to 32,767
unsigned short int 2 bytes 0 to 65,535
long 4 bytes -2,147,483,648 to 2,147,483,647
unsigned long 4 bytes 0 to 4,294,967,295
long long 8 bytes -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
unsigned long long 8 bytes 0 to 18,446,744,073,709,551,615

◼ The int data type is 32-bit in Arm. It is 16-bit in 16-bit and 8-bit processors.

Faculty of Electrical Engineering, GIK Institute 29


30

Data types (cont.)


◼ char c; c ◼ long lng; lng
◼ int8_t c; ◼ int32_t lng;

a1 a
◼ short int a1; ◼ uint16_t a;
◼ int16_t a1; ◼ unsigned short a;

What is the difference between signed and unsigned integers?

Faculty of Electrical Engineering, GIK Institute


Arm families and Architectures

Faculty of Electrical Engineering, GIK Institute 31


Arm MCUs of Different Companies
• The same CPU and programming Language
• Different Peripherals

Faculty of Electrical Engineering, GIK Institute 32


STM32 Family
• ST is a multinational
company
– STM8: 8-bit MCUs
– STM32: 32-bit MCUs
based on Arm
•Low prices
•Various chips

Faculty of Electrical Engineering, GIK Institute 33


ST32 Naming Conventions

STM32F103C8T
type series package
family
Sub Pin Flash
series count size
Family Series
Type
Flash Package
Pin count
size
Sub series
L:0:Low
Names of the new Cortex-M0
H:Chips
Arm BGAwith
Power (Ballhigher
Grid Array)
4 8 F of
6products GB K C
1,2: with
T:LQFP T
Cortex-M3DS
(Low-profile C
E RF VG ZH I
F: ST
Mainstream
begin sub-seriesQuad Flat Pack)
(Foundation)
Group Number
Low Medium density
20STM32.
28 32
3,4: High
36 density
Cortex-M4
U:QFN 44 have
(Quad 48No-leads)
Flat 64 100 144
H: High performance
numbers
density
of pins 7: Cortex-M7
W: Y:WLCSP
Wirelessricher
Flash 16K 32K 64K 128K 256K 384K 512K 768K 1M 1.5M 2M
configurations

STM32F429AIH6 STM32F103C8T6 STM32F031K6U6

Faculty of Electrical Engineering, GIK Institute 34


STM32F103

Faculty of Electrical Engineering, GIK Institute 35


Lab…

Faculty of Electrical Engineering, GIK Institute 36


Lab…

Faculty of Electrical Engineering, GIK Institute 37

You might also like