Internship Report
Internship Report
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.
Dept. of ECE,AIEMS 1
Embedded System Design using STM ARM Microcontroller 2022-23
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
– 72 MHz maximum frequency, 1.25 DMIPS / MHz (Dhrystone 2.1) performance at 0 wait
state memory access
Memories
– 20 Kbytes of SRAM
– Internal 40 kHz RC
Dept. of ECE,AIEMS 3
Embedded System Design using STM ARM Microcontroller 2022-23
Low-power
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
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
– Up to three USARTs (ISO 7816 interface, LIN, IrDA capability, modem control)
Dept. of ECE,AIEMS 4
Embedded System Design using STM ARM Microcontroller 2022-23
CHAPTER 3
ELECTRICAL CHARACTERISTICS- PARAMETER
CONDITIONS
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).
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σ).
C = 50 pF VIN
ai14141 ai14142
Dept. of ECE,AIEMS 5
Embedded System Design using STM ARM Microcontroller 2022-23
CHAPTER 4
STM32 CUBE IDE
STM32CubeMX, a graphical software configuration tool that allows the automatic generation
of C initialization code using graphical wizards.
Dept. of ECE,AIEMS 6
Embedded System Design using STM ARM Microcontroller 2022-23
CHAPTER 5
STM32 GPIO PIN
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
Dept. of ECE,AIEMS 7
Embedded System Design using STM ARM Microcontroller 2022-23
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
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.
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
Dept. of ECE,AIEMS 10
Embedded System Design using STM ARM Microcontroller 2022-23
CHAPTER 7
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
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.
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
Dept. of ECE,AIEMS 13
Embedded System Design using STM ARM Microcontroller 2022-23
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
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.
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
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
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
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
Dept. of ECE,AIEMS 19