100% found this document useful (1 vote)
309 views19 pages

Internship Report

This document discusses embedded system design using STM32 ARM microcontrollers. Chapter 1 introduces STM32 microcontrollers and how to connect an ST-Link programmer. Chapter 2 describes the STM32F103x8 family board features. Chapter 3 discusses electrical characteristics and parameter conditions. Chapter 4 presents the STM32 Cube IDE. Chapter 5 covers STM32 GPIO pins for digital input and output. Chapter 6 examines STM32 timer PWM mode.

Uploaded by

USHA VENKATESH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
309 views19 pages

Internship Report

This document discusses embedded system design using STM32 ARM microcontrollers. Chapter 1 introduces STM32 microcontrollers and how to connect an ST-Link programmer. Chapter 2 describes the STM32F103x8 family board features. Chapter 3 discusses electrical characteristics and parameter conditions. Chapter 4 presents the STM32 Cube IDE. Chapter 5 covers STM32 GPIO pins for digital input and output. Chapter 6 examines STM32 timer PWM mode.

Uploaded by

USHA VENKATESH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Embedded System Design using STM ARM Microcontroller 2022-23

CHAPTER 1
INTRODUCTION TO STM32
STM32 is a family of 32-bit microcontroller integrated circuits by STMicroelectronics. The
STM32 chips are grouped into related series that are based around the same 32-
bit ARM processor core, such as the Cortex-M33F, Cortex-M7F, Cortex-M4F, Cortex-
M3, Cortex-M0+, or Cortex-M0. Internally, each microcontroller consists of the processor
core, static RAM, flash memory, debugging interface, and various peripherals. This low-cost
STM32 series development board comes with an STM32F103C8T6 microcontroller.
STM32F103C8T6 is one of the mid-range microcontroller units of the STM32F103x8 family
based on RISC architecture. An integrated Blue Pill Development Board was introduced as a
low-cost board as an alternative to STMicroelectronics STM discovery boards. The price of
Blue Pill is around 2-3$.

STM32F103C8T6 microcontroller comes with GPIO pins, processor, memory, USB port,
Analog to Digital Converters, and other peripherals. An ARM Cortex Core with an amazing
speed of 72 MHz and remarkable power efficiency.

This internship focuses on STM32F103C8 microcontroller featured by ARM Cortex-M and


how to program it using STM32Cube. STM32Cube is an IDE provided by STM32 itself.

Figure 1.1: STM32 Microcontroller

Dept. of ECE,AIEMS 1
Embedded System Design using STM ARM Microcontroller 2022-23

Figure 1.2:STM32 Microcontroller pin diagram

1.1 CONNECTING ST-LINK PROGRAMMER WITH STM32


To upload the code to our STM32 board. To do that, first we will have to connect our Blue
Pill STM32 with a ST-Link programmer. We will be using ST-Link V2.

Table 1.1: ST Linker Pin Configuration

Figure 1.3: ST Linker

Dept. of ECE,AIEMS 2
Embedded System Design using STM ARM Microcontroller 2022-23

CHAPTER 2
STM32F103x8 Family Board
The STM32F103xx medium-density performance line family incorporates the high-
performance Arm Cortex-M3 32-bit RISC core operating at a 72 MHz frequency, high-speed
embedded memories (Flash memory up to 128 Kbytes and SRAM up to 20 Kbytes), and an
extensive range of enhanced I/Os and peripherals connected to two APB buses. All devices
offer two 12-bit ADCs, three general purpose 16-bit timers plus one PWM timer, as well as
standard and advanced communication interfaces: up to two I2Cs and SPIs, three USARTs,
an USB and a CAN.

2.1 FEATURES

Arm 32-bit Cortex-M3 CPU core

– 72 MHz maximum frequency, 1.25 DMIPS / MHz (Dhrystone 2.1) performance at 0 wait
state memory access

– Single-cycle multiplication and hardware division.

 Memories

– 64 or 128 Kbytes of Flash memory

– 20 Kbytes of SRAM

 Clock, Reset and Supply management

– 2.0 to 3.6 V application supply and I/Os

– POR, PDR, and programmable voltage detector (PVD)

– 4 to 16 MHz crystal oscillator

– Internal 8 MHz factory-trimmed RC

– Internal 40 kHz RC

– PLL for CPU clock

– 32 kHz oscillator for RTC with calibration.

Dept. of ECE,AIEMS 3
Embedded System Design using STM ARM Microcontroller 2022-23

 Low-power

– Sleep, Stop and Standby modes

– VBAT supply for RTC and backup registers.

 DMA

– 7-channel DMA controller, Peripherals supported: timers, ADC, SPIs, I 2Cs and USARTs
 Up to 80 fast I/O ports

– 26/37/51/80 I/Os, all mappable on 16 external interrupt vectors and almost all 5 V-tolerant.

 Debug mode

– Serial wire debug (SWD) and JTAG interfaces.

 Seven timers

– Three 16-bit timers, each with up to 4 IC/OC/PWM or pulse counter and quadrature
(incremental) encoder input

– 16-bit, motor control PWM timer with dead-time generation and emergency stop

– Two watchdog timers (independent and window)

– SysTick timer 24-bit down counter.

 Up to nine communication interfaces

– Up to two I2C interfaces

– Up to three USARTs (ISO 7816 interface, LIN, IrDA capability, modem control)

– Up to two SPIs (18 Mbit/s)

– CAN interface (2.0B Active)

– USB 2.0 full-speed interface.

 CRC calculation unit, 96-bit unique ID.

Dept. of ECE,AIEMS 4
Embedded System Design using STM ARM Microcontroller 2022-23

CHAPTER 3
ELECTRICAL CHARACTERISTICS- PARAMETER
CONDITIONS

3.1 MINIMUM AND MAXIMUM VALUES

Unless otherwise specified the minimum and maximum values are guaranteed in the worst
conditions of ambient temperature, supply voltage and frequencies by tests in production on
100% of the devices with an ambient temperature at TA = 25 °C and TA = TAmax (given by
the selected temperature range).

3.2 TYPICAL VALUES

Unless otherwise specified, typical data are based on T A = 25 °C, VDD = 3.3 V. They are
given only as design guidelines and are not tested. Typical ADC accuracy values are
determined by characterization of a batch of samples from a standard diffusion lot over the
full temperature range, where 95% of the devices have an error less than or equal to the value
indicated (mean ± 2σ).

3.3 TYPICAL CURVES


Unless otherwise specified, all typical curves are given only as design guidelines and are not
tested.

3.4 LOADING CAPACITOR AND PIN INPUT VOLTAGE

Pin loading conditions Pin input voltage

STM32F103xx pin STM32F103xx pin

C = 50 pF VIN

ai14141 ai14142

Figure 3.1: Pin loading Conditions and Pin input voltage

Dept. of ECE,AIEMS 5
Embedded System Design using STM ARM Microcontroller 2022-23

CHAPTER 4
STM32 CUBE IDE

Figure 4.1: STM32 Cube IDE

STM32Cube is a STMicroelectronics original initiative to significantly improve designer


productivity by reducing development effort, time, and cost. STM32Cube covers the whole
STM32 portfolio. STM32Cube includes:

A set of user-friendly software development tools to cover project development from


conception to realization, among which are:

STM32CubeMX, a graphical software configuration tool that allows the automatic generation
of C initialization code using graphical wizards.

STM32CubeIDE, an all-in-one development tool with peripheral configuration, code


generation, code compilation, and debug features.

STM32CubeProgrammer (STM32CubeProg), a programming tool available in graphical and


command line versions – STM32CubeMonitor (STM32CubeMonitor, STM32CubeMonPwr,
STM32CubeMonRF, STM32CubeMonUCPD) powerful monitoring tools to fine-tune the
behaviour and performance of STM32 applications in real-time.

STM32Cube MCU and MPU Packages, comprehensive embedded-software platforms


specific to each microcontroller and microprocessor series (such as STM32CubeF4 for the
STM32F4 Series), which include:STM32Cube hardware abstraction layer (HAL), ensuring
maximized portability across the STM32 portfolio – STM32Cube low-layer APIs, ensuring
the best performance and footprints with a high degree of user control over hardware.

Dept. of ECE,AIEMS 6
Embedded System Design using STM ARM Microcontroller 2022-23

CHAPTER 5
STM32 GPIO PIN

5.1 GPIO WRITE PIN DIGITAL OUTPUT


We’ll configure a GPIO pin to be output. Then, we’ll do the first LED blinking with the
STM32 blue pill board. You’ll learn all the steps to configure the STM32 Cube MX and flash
the code from Cube IDE to the board and start testing.

OBJECTIVES:
1. Configure GPIO Output Pin Within CubeMX Tool
2. Use HAL_GPIO_Write to Change the Pin State
3. And Use The HAL_Delay () & Know How It Works

Figure 5.1: GPIO Write Pin Digital Output

Dept. of ECE,AIEMS 7
Embedded System Design using STM ARM Microcontroller 2022-23

5.2 GPIO READ PIN DIGITAL INPUT


We’ll configure a GPIO pin to be output. Another one to be an input. Then, we’ll write a
simple application to switch an LED ON when a Switch is pressed. You’ll learn all the steps
to configure the STM32 CubeMX and flash the code from Cube IDE to the board and start
testing.

OBJECTIVES:
1. Configure GPIO Output Pin & Input Pin Within CubeMX Tool
2. Use HAL_GPIO_ReadPin to Read the Push Button State
3. Use HAL_GPIO_Write to Change the Pin State

Figure 5.2: GPIO Read PIN Digital Input

Dept. of ECE,AIEMS 8
Embedded System Design using STM ARM Microcontroller 2022-23

CHAPTER 6
STM32 TIMER PWM MODE
STM32 PWM generation using STM32 timer modules in the PWM mode. You’ll get to know
how the PWM signal is generated, how to control its frequency, duty cycle, and how to
estimate the PWM resolution. And how to set up the timer module to operate in PWM mode
and write a simple application to make an LED dimmer. 
The timer modules can operate a variety of modes one of which is the PWM mode. Where
the timer gets clocked from an internal source and counts up to the auto-reload register value,
then the output channel pin is driven HIGH. And it remains until the timer counts reach the
CCRx register value, the match event causes the output channel pin to be driven LOW. And it
remains until the timer counts up to the auto-reload register value, and so on. The resulting
waveform is called PWM (pulse-width modulated) signal. The PWM doesn’t always have to
be following this exact same procedure for PWM generation, however, it’s the very basic one
and the easier to understand the concept. It’s called the up-counting PWM mode. We’ll
discuss further advanced PWM generation techniques as we go on in this series of tutorials.

The following diagram shows you how the ARR value affects the period (frequency) of the
PWM signal. And how the CCRx value affects the corresponding PWM signal’s duty cycle.
And illustrates the whole process of PWM signal generation in the up-counting normal mode.

Figure 6.1: STM32 Timer PWM Wave

Dept. of ECE,AIEMS 9
Embedded System Design using STM ARM Microcontroller 2022-23

Objectives
1. To build a system that sweeps the duty cycle of the PWM channel1 from 0 up to
100% back and forth.
2. So that the LED brightness follows the same pattern.
3. The auto-reload register will be set to a maximum value which is 65535, for no
particular reason.
4. But you should know that the output FPWM frequency is expected to be 1098.6Hz 

Figure 6.2: STM32 Timer PWM

Dept. of ECE,AIEMS 10
Embedded System Design using STM ARM Microcontroller 2022-23

CHAPTER 7

STM32 LIGHT SENSOR (LDR) INTERFACING – AMBIENT


LIGHT SENSOR PROJECT

Figure 8.1: LDR

An LDR is a light-dependent resistor, it’s an electronic device that is being used for light
intensity sensing applications. The LDR has a relatively low resistance in light, and when the
surrounding gets darker the LDR’s resistance significantly increases. Hence, we can make a
voltage divider circuit using the LDR and a fixed resistor and use the microcontroller’s ADC
to measure the voltage which indicates the resistance value or the light intensity level. An
LDR can have a resistance of 5kΩ in daylight, 8kΩ in room light, and up to 2MΩ in
darkness.

Dept. of ECE,AIEMS 11
Embedded System Design using STM ARM Microcontroller 2022-23

Figure 8.2: LDR Symbol

In this project we’ll estimate the ambient light level and set it as a base level and whenever
the light intensity gets lower (surrounding darkens) the LED PWM duty cycle increase and
the LED gets brighter.

Figure 8.3: STM32 ADC circuit diagram with LDR

Dept. of ECE,AIEMS 12
Embedded System Design using STM ARM Microcontroller 2022-23

On power-up, the system estimates the nominal or normal ambient light intensity in your
room and set it to be the base for further calculations. That’s why you’ve got to make sure
that there is light facing the LDR when powering up the system. Recalibration can be
achieved by holding the reset button while providing sufficient light facing the sensor
surface.

-Configure The ADC1 Peripheral, Enable Channel7 & Set it to be triggered by software

Figure 8.4: STM32 ADC enabling channel7

-Configure Timer2 to Operate in PWM Mode with Output on CH1

Dept. of ECE,AIEMS 13
Embedded System Design using STM ARM Microcontroller 2022-23

Figure 8.5: STM32 ADC Configure Timer2

Figure 8.6: STM32 ADC with LDR output

OUTPUT:
In this Project, LDR is the major focus. An LDR is a light-dependent resistor, it’s an
electronic device that is being used for light intensity sensing applications. The circuit
diagram is shown in figure 8.6 where LDR is placed, when the surrounding gets darker the
LDR’s resistance significantly increases and LED turns ON. And when the surrounding gets
brighter the LDR’s resistance significantly decreases and LED turns OFF. Hence there is no
Wastage of Energy.

Dept. of ECE,AIEMS 14
Embedded System Design using STM ARM Microcontroller 2022-23

CHAPTER 8
SMOKE SENSOR WITH BUZZER USING STM32
MICROCONTROLLER

Figure 9.1: Smoke Sensor

A smoke detector is a device that senses smoke, typically as an indicator of fire. Smoke
detectors are usually housed in plastic enclosures, typically shaped like a disk about 150 mm
(6 in) in diameter and 25 mm (1 in) thick, but shape and size vary. Smoke can be detected
either optically (photoelectric) or by physical process (ionization). Detectors may use one or

Dept. of ECE,AIEMS 15
Embedded System Design using STM ARM Microcontroller 2022-23

both sensing methods. Sensitive alarms can be used to detect and deter smoking in banned
areas. Smoke detectors in large commercial and industrial buildings are usually connected to
a central fire alarm system.

Household smoke detectors, also known as smoke alarms, generally issue an audible or
visual alarm from the detector itself or several detectors if there are multiple devices
interlinked. Household smoke detectors range from individual battery-powered units to
several interlinked units with battery backup. With interlinked units, if any unit detects
smoke, alarms will trigger at all of the units. This happens even if household power has gone
out.

Figure 9.2: Smoke Sensor with buzzer output

OUTPUT:
In this Project we use Smoke sensor for the detection of smoke and sensitive alarms are used
to detect the smoke. This Sensor senses the smoke in the surrounding and the Buzzer beeps.
Hence the as soon as the smoke is sensed, the buzzer beeps and the person can work on the
situation.

Dept. of ECE,AIEMS 16
Embedded System Design using STM ARM Microcontroller 2022-23

CHAPTER 9
PIR SENSOR WITH LED USING STM32
MICROCONTROLLER

Figure 11.1: PIR Sensor

PIR Sensor is an electronic sensor that measures infrared light radiating from objects. PIR
sensors mostly used in PIR-based motion detectors. Also, it used in security alarms and
automatic lighting applications. The below image shows a typical pin configuration of the
PIR sensor, which is quite simple to understand the pinouts. The PIR sensor consists of 3
pins, they are:

Dept. of ECE,AIEMS 17
Embedded System Design using STM ARM Microcontroller 2022-23

Figure 10.2: PIR Sensor in detail

 Pin1 corresponds to the drain terminal of the device, which connected to the positive
supply 5V DC.

Pin2 corresponds to the source terminal of the device, which connects to the ground terminal
via a 100K or 47K resistor. The Pin2 is the output pin of the sensor. The pin 2 of the sensor
carries the detected IR signal to an amplifier from the

Pin3 of the sensor connected to the ground.

Figure 10.3: PIR Sensor output

The passive infrared sensor does not radiate energy to space. It receives the infrared radiation
from the human body to make an alarm. Any object with temperature is constantly radiating

Dept. of ECE,AIEMS 18
Embedded System Design using STM ARM Microcontroller 2022-23

infrared rays to the outside world. The surface temperature of the human body is between 36° C
- 27 ° C and most of its radiant energy concentrated in the wavelength range of 8 um-12 um.

OUTPUT:
This Project uses PIR sensor for the detection. PIR Sensor is an electronic sensor that
measures infrared light radiating from objects. PIR sensors mostly used in PIR-based motion
detectors. When the motion or heat is detected by the PIR sensor, the LED which is
connected the circuit turns ON. Hence when some motion is sensed, the output is given as
ON and OFF of LED.

CONCLUSION

In conclusion, my internship experience at Ambience technology, Kengeri, Bangalore was


valuable. Through it, I gained valuable skills in Embedded system & problem-solving, as
well as a better understanding of the different aspects of a microcontroller on STM32
Microcontroller, STM32 cube IDE, about different sensors like Smoke sensor, PIR sensor,
about LDR, PWM-to-DAC output and many other features and their applications. The
knowledge I have acquired will benefit me in my future endeavors.

Dept. of ECE,AIEMS 19

You might also like