Embedded System Design with Arm Cortex-M Microcontrollers - Applications with C, C++

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

This textbook introduces basic and advanced embedded system topics through ARM Cortex M microcontrollers, covering programmable microcontroller usage starting from basic to advanced concepts using the STMicroelectronics Discovery development board. Designed for use in upper-level undergraduate and graduate courses on microcontrollers, microprocessor systems, and embedded systems, the book explores fundamental and advanced topics, real-time operating systems via FreeRTOS and Mbed OS, and then offers a solid grounding in digital signal processing, digital control, and digital image processing concepts — with emphasis placed on the usage of a microcontroller for these advanced topics. The book uses C language, “the” programming language for microcontrollers, C++ language, and MicroPython (which is s.hite), which allows Python language usage on a microcontroller. Sample codes and course slides are available for readers and instructors, and a solutions manual is available to instructors. The book will also be an ideal reference for practicing engineers and electronics hobbyists who wish to become familiar with basic and advanced microcontroller concepts. Teaches the embedded system design skills needed for today’s job market; Thoroughly explains each concept and provides illustrated examples and projects; Covers fundamental and advanced embedded system topics, real-time operating systems, digital signal processing, digital control, and digital image processing on microcontrollers.

Author(s): Cem Ünsalan et al
Edition: 1
Publisher: Springer
Year: 2022

Language: English
Pages: 576
Tags: c c++17 c++20 c17 embedded arm cortex 2022

Contents
1 Introduction
1.1 Embedded Systems
1.2 Microcontroller as Embedded System
1.3 About the Book
References
2 Microcontroller Architecture
2.1 The STM32F4 Microcontroller
2.1.1 Central Processing Unit
2.1.1.1 Nested Vectored Interrupt Controller
2.1.1.2 Debug Access Port and Serial Wire Viewer
2.1.1.3 Memory Management Units
2.1.1.4 Embedded Trace Macrocell Module
2.1.1.5 The Bus Matrix
2.1.1.6 Registers
2.1.2 Memory
2.1.2.1 Memory Types
2.1.2.2 Memory Map
2.1.2.3 Memory Related Modules
2.1.3 General-Purpose Input and Output Ports
2.1.4 Clock and Timer Modules
2.1.5 Analog Modules
2.1.6 Digital Communication Modules
2.1.7 Other Modules
2.2 Assembly Language
2.2.1 The Arm® Cortex™-M4 Instruction Set
2.2.2 Executing Machine Language Code in the Microcontroller
2.3 The STM32F4 Board
2.3.1 General Information
2.3.2 Pin Layout
2.3.3 Powering the Board and Programming the Microcontroller on It
2.4 Summary of the Chapter
Problems
References
3 Software Development Platforms
3.1 The STM32CubeIDE Platform
3.1.1 Downloading and Installing STM32CubeIDE
3.1.2 Launching STM32CubeIDE
3.1.3 Creating a New Project
3.1.4 Building, Debugging, and Executing the Project
3.1.4.1 Building and Debugging the Project
3.1.4.2 Executing the Project
3.1.5 Using STM32CubeMX to Modify Hardware of the Microcontroller
3.1.5.1 Creating a New Project Using STM32CubeMX
3.1.5.2 Generating and Modifying the Code
3.1.5.3 Executing the Project
3.2 Mbed and Mbed Studio Platforms
3.2.1 Mbed on Web
3.2.2 Managing a Project in Mbed
3.2.2.1 Creating the Project
3.2.2.2 Building and Executing the Project
3.2.3 Mbed Studio on Desktop
3.2.4 Managing a Project in Mbed Studio
3.2.4.1 Creating the Project
3.2.4.2 Building, Debugging, and Executing the Project
3.3 MicroPython
3.3.1 About Python
3.3.2 Python for Microcontrollers: MicroPython
3.3.3 Setting up MicroPython on the STM32F4 Microcontroller
3.3.4 MicroPython Working Principles
3.3.5 Using MicroPython on the STM32F4 Microcontroller
3.3.5.1 Read-Evaluate-Print Loop
3.3.5.2 Accessing and Modifying the Main File
3.3.5.3 Using an Available Python IDE
3.4 Application: Tools for Analyzing the Generated Code
3.4.1 Analyzing the C Code in STM32CubeIDE
3.4.1.1 The Instrumentation Trace Macrocell Usage
3.4.1.2 Measuring the Execution Time
3.4.1.3 Measuring Memory Usage
3.4.2 Analyzing the C++ Code in Mbed Studio
3.4.2.1 Measuring the Execution Time
3.4.2.2 Measuring Memory Usage
3.4.3 Analyzing the MicroPython Code
3.4.3.1 Measuring the Execution Time
3.4.3.2 Measuring Memory Usage
3.5 Summary of the Chapter
Problems
References
4 Digital Input and Output
4.1 Bit Values as Voltage Levels
4.2 Interfacing Voltage Levels with the Microcontroller
4.2.1 Digital Input from a Switch or Button
4.2.1.1 Setting Up the Switch or Button
4.2.1.2 Avoiding Switch Bouncing
4.2.2 Digital I/O with High Voltage Values
4.2.3 Digital Output to a Load Requiring High Current and Voltage Values
4.3 Digital I/O Setup on the STM32F4 Microcontroller
4.3.1 Circuit Diagram of a Pin and Its Setup via Associated Registers
4.3.2 GPIO Registers in Memory Map of the STM32F4 Microcontroller
4.3.3 Setting Up GPIO Registers
4.3.3.1 C Language
4.3.3.2 C++ Language
4.3.3.3 MicroPython
4.4 Digital I/O Usage on the STM32F4 Microcontroller
4.4.1 C Language Usage
4.4.2 C++ Language Usage
4.4.3 MicroPython Usage
4.5 Application: Digital Input and Output Operations in the Robot Vacuum Cleaner
4.6 Summary of the Chapter
Problems
References
5 Interrupts and Power Management
5.1 The Interrupt Concept in Embedded Systems
5.1.1 Interrupts in General
5.1.2 Interrupts in the STM32F4 Microcontroller
5.1.2.1 Interrupt Operations in Peripheral Units
5.1.2.2 Extended Interrupts and Events Controller
5.1.2.3 Nested Vectored Interrupt Controller
5.1.2.4 Interrupt Operations in the CPU
5.2 Interrupt Setup in the STM32F4 Microcontroller
5.2.1 Interrupt Setup via C Language
5.2.2 Interrupt Setup via C++ Language
5.2.3 Interrupt Setup via MicroPython
5.3 Interrupt Usage in the STM32F4 Microcontroller
5.3.1 Interrupt Usage via C Language
5.3.2 Interrupt Usage via C++ Language
5.3.3 Interrupt Usage via MicroPython
5.4 Power Management in Embedded Systems
5.4.1 Importance of Power Management in Embedded Applications
5.4.2 The Link Between Power Management and Interrupt Usage
5.4.3 Battery as Power Supply
5.5 Power Management in the STM32F4 Microcontroller
5.5.1 Power Management Features
5.5.2 Power Supply Options
5.5.3 Power Modes
5.5.4 STM32CubeMX for Power Usage Analysis
5.6 Usage of Power Modes in Code
5.6.1 Power Modes in C Language
5.6.1.1 Sleep Mode
5.6.1.2 Stop Mode
5.6.1.3 Standby Mode
5.6.2 Power Modes in C++ Language
5.6.3 Power Modes in MicroPython
5.7 Application: Interrupt-Based Operations and Power Management for the Robot Vacuum Cleaner
5.8 Summary of the Chapter
Problems
References
6 Timing Operations
6.1 Clock Signals in Embedded Systems
6.1.1 What Is a Clock Signal?
6.1.2 Oscillator as the Clock Signal Source
6.1.3 Managing Clocks in the STM32F4 Microcontroller
6.2 Timers in Embedded Systems
6.2.1 What Is a Timer?
6.2.2 Introducing Timers in the STM32F4 Microcontroller
6.2.3 Base Timers in the STM32F4 Microcontroller
6.2.3.1 Trigger and Clock Controller Block
6.2.3.2 The Counter Block
6.2.3.3 Counting Modes
6.2.3.4 The Input Capture Block
6.2.3.5 The Output Compare Block
6.2.3.6 Summary of the STM32F4 Microcontroller Base Timers
6.2.4 System Timer in the STM32F4 Microcontroller
6.2.5 Watchdog Timers in the STM32F4 Microcontroller
6.2.6 Real-Time Clock in the STM32F4 Microcontroller
6.2.7 Advanced Base Timer Operations in the STM32F4 Microcontroller
6.3 Timer Setup in the STM32F4 Microcontroller
6.3.1 Timer Setup via C Language
6.3.1.1 Setting Up Base Timers
6.3.1.2 Setting Up the System Timer
6.3.1.3 Setting Up Watchdog Timers
6.3.1.4 Setting Up the RTC
6.3.2 Timer Setup via C++ Language
6.3.2.1 Setting Up Base Timers
6.3.2.2 Setting Up the Watchdog Timer
6.3.2.3 Setting Up the RTC
6.3.3 Timer Setup via MicroPython
6.3.3.1 Setting Up Base Timers
6.3.3.2 Setting Up the Watchdog Timer
6.3.3.3 Setting Up the RTC
6.4 Timer Usage in the STM32F4 Microcontroller
6.4.1 Timer Usage in C Language
6.4.1.1 Usage of Base Timers
6.4.1.2 Usage of the System Timer
6.4.1.3 Usage of Watchdog Timers
6.4.1.4 Usage of the RTC
6.4.1.5 Timer Usage Examples via C Language
6.4.2 Timer Usage in C++ Language
6.4.2.1 Usage of Base Timers
6.4.2.2 Usage of the Watchdog Timer
6.4.2.3 Usage of the RTC
6.4.2.4 Timer Usage Examples via C++ Language
6.4.3 Timer Usage in MicroPython
6.4.3.1 Usage of Base Timers
6.4.3.2 Usage of the Watchdog Timer
6.4.3.3 Usage of the RTC
6.4.3.4 Timer Usage Examples via MicroPython
6.5 Application: Timing Operations in the Robot Vacuum Cleaner
6.6 Summary of the Chapter
Problems
References
7 Conversion Between Analog and Digital Values
7.1 Analog and Digital Values
7.1.1 Analog Values in Physical Systems
7.1.2 Digital Values in Embedded Systems
7.1.3 Digital Values in Code
7.1.3.1 Data Types in C and C++ Languages
7.1.3.2 Data Types in Python
7.2 Analog to Digital Conversion in Embedded Systems
7.2.1 Sampling
7.2.2 Quantization
7.2.3 ADC Operation in the STM32F4 Microcontroller
7.2.3.1 Input Sources
7.2.3.2 Triggers
7.2.3.3 Operating Modes
7.2.3.4 ADC Interrupts
7.2.3.5 Sampling and Clocks
7.2.3.6 Obtaining the ADC Operation Result
7.3 ADC Setup in the STM32F4 Microcontroller
7.3.1 ADC Setup via C Language
7.3.1.1 Setting Up Input Sources
7.3.1.2 Setting Up Operating Modes
7.3.1.3 Setting Up ADC Interrupts
7.3.1.4 Setting Up Triggers
7.3.1.5 Setting Up Clock Options
7.3.2 ADC Setup via C++ Language
7.3.3 ADC Setup via MicroPython
7.4 ADC Usage in the STM32F4 Microcontroller
7.4.1 ADC Usage in C Language
7.4.1.1 Starting and Stopping the Conversion Operation
7.4.1.2 The Injected Conversion Operation
7.4.1.3 ADC Interrupt Usage
7.4.1.4 The ADC Module Usage Examples
7.4.2 ADC Usage in C++ Language
7.4.3 ADC Usage in MicroPython
7.5 Digital to Analog Conversion in Embedded Systems
7.5.1 Zero-Order Hold
7.5.2 Pulse Width Modulation
7.5.3 DAC Operation in the STM32F4 Microcontroller
7.5.3.1 The DAC Module
7.5.3.2 PWM Signal Generation
7.6 DAC Setup in the STM32F4 Microcontroller
7.6.1 DAC Setup via C Language
7.6.1.1 DAC Module Setup
7.6.1.2 PWM Signal Setup
7.6.2 DAC Setup via C++ Language
7.6.3 DAC Setup via MicroPython
7.7 DAC Usage in the STM32F4 Microcontroller
7.7.1 DAC Usage in C Language
7.7.1.1 DAC Module Usage
7.7.1.2 PWM Signal Usage
7.7.1.3 DAC Usage Examples
7.7.2 DAC Usage in C++ Language
7.7.3 DAC Usage in MicroPython
7.8 Application: ADC and DAC Operations in the Robot Vacuum Cleaner
7.9 Summary of the Chapter
Problems
References
8 Digital Communication
8.1 Background on Digital Communication
8.1.1 Data, Frame, and Field
8.1.2 Serial and Parallel Data Transfer
8.1.3 Synchronous and Asynchronous Data Transfer
8.1.4 Signal Representation and Line Formations
8.1.5 Data Encoding Types
8.1.5.1 Non Return to Zero
8.1.5.2 Return to Zero
8.1.5.3 Non Return to Zero Inverted
8.1.5.4 Return to Zero Inverted
8.1.5.5 Manchester Coding
8.1.5.6 Demonstrating Different Data Encoding Types
8.1.6 Simplex, Half, and Full Duplex Communication
8.1.7 Master and Slave Modes
8.1.8 Baud Rate
8.2 Universal Asynchronous Receiver/Transmitter
8.2.1 UART Working Principles
8.2.2 UART Modules in the STM32F4 Microcontroller
8.2.3 UART Setup in the STM32F4 Microcontroller
8.2.3.1 Setup via C Language
8.2.3.2 Setup via C++ Language
8.2.3.3 Setup via MicroPython
8.2.4 UART Usage in the STM32F4 Microcontroller
8.2.4.1 Usage via C Language
8.2.4.2 Usage via C++ Language
8.2.4.3 Usage via MicroPython
8.3 Serial Peripheral Interface
8.3.1 SPI Working Principles
8.3.2 SPI Modules in the STM32F4 Microcontroller
8.3.3 SPI Setup in the STM32F4 Microcontroller
8.3.3.1 Setup via C Language
8.3.3.2 Setup via C++ Language
8.3.3.3 Setup via MicroPython
8.3.4 SPI Usage in the STM32F4 Microcontroller
8.3.4.1 Usage via C Language
8.3.4.2 Usage via C++ Language
8.3.4.3 Usage via MicroPython
8.4 Inter-integrated Circuit
8.4.1 I2C Working Principles
8.4.2 I2C Modules in the STM32F4 Microcontroller
8.4.3 I2C Setup in the STM32F4 Microcontroller
8.4.3.1 Setup via C Language
8.4.3.2 Setup via C++ Language
8.4.3.3 Setup via MicroPython
8.4.4 I2C Usage in the STM32F4 Microcontroller
8.4.4.1 Usage via C Language
8.4.4.2 Usage via C++ Language
8.4.4.3 Usage via MicroPython
8.5 Controller Area Network
8.5.1 CAN Working Principles
8.5.2 CAN Modules in the STM32F4 Microcontroller
8.5.3 CAN Setup in the STM32F4 Microcontroller
8.5.3.1 Setup via C Language
8.5.3.2 Setup via C++ Language
8.5.3.3 Setup via MicroPython
8.5.4 CAN Usage in the STM32F4 Microcontroller
8.5.4.1 Usage via C Language
8.5.4.2 Usage via C++ Language
8.5.4.3 Usage via MicroPython
8.6 Universal Serial Bus
8.6.1 USB Working Principles
8.6.2 USB Modules in the STM32F4 Microcontroller
8.6.3 USB Setup in the STM32F4 Microcontroller
8.6.3.1 Setup via C Language
8.6.3.2 Setup via MicroPython
8.6.4 USB Usage in the STM32F4 Microcontroller
8.6.4.1 Usage via C Language
8.6.4.2 Usage via MicroPython
8.7 Other Digital Communication Types
8.7.1 SD Bus Interface
8.7.2 Inter-IC Sound
8.8 Application: Digital Communication for the Robot Vacuum Cleaner
8.9 Summary of the Chapter
Problems
References
9 Memory Operations
9.1 Memory Working Principles
9.1.1 Bus Architecture
9.1.2 Memory in General
9.1.3 RAM
9.1.4 Flash Memory
9.2 Memory Management in C and C++ Languages
9.2.1 RAM Partitioning
9.2.2 Memory Modification
9.2.3 Pointer-Based Operations
9.2.3.1 Pointer to a Variable
9.2.3.2 Pointer to a Pointer
9.2.3.3 Reaching a Specific Memory Address by Pointers
9.2.3.4 Pointers and Arrays
9.2.3.5 Pointer to a Structure
9.2.3.6 Function Call by Reference
9.2.3.7 Function Pointers
9.2.4 Local, Global, and Static Variables
9.3 Memory Management in MicroPython
9.3.1 RAM Management During Compilation Stage
9.3.1.1 Frozen Bytecode Usage
9.3.1.2 Precompiling Scripts
9.3.2 Effective RAM Usage During Code Execution
9.3.2.1 Constant Usage
9.3.2.2 Constant Data Structures
9.3.2.3 Using Pre-allocated Buffers
9.3.2.4 Garbage Collector
9.3.3 Local and Global Variables
9.4 Direct Memory Access
9.4.1 The DMA Controller in the STM32F4Microcontroller
9.4.2 DMA Features
9.4.3 DMA Interrupts
9.4.4 DMA Setup in the STM32F4 Microcontroller
9.4.5 DMA Usage in the STM32F4 Microcontroller
9.5 Flexible Memory Controller
9.5.1 FMC Working Principles
9.5.2 FMC Setup in the STM32F4 Microcontroller
9.5.2.1 Setup via C Language
9.5.2.2 Setup via C++ Language
9.5.2.3 Setup via MicroPython
9.5.3 FMC Usage in the STM32F4 Microcontroller
9.5.3.1 Usage via C Language
9.5.3.2 Usage via C++ Language
9.5.3.3 Usage via MicroPython
9.6 Application: Memory-Based Operations in the Robot Vacuum Cleaner
9.7 Summary of the Chapter
Problems
References
10 Real-Time Operating Systems
10.1 Fundamentals of RTOS
10.1.1 RTOS Components
10.1.2 RTOS Working Principles
10.2 FreeRTOS and Mbed OS
10.2.1 FreeRTOS
10.2.2 FreeRTOS Project Setup in STM32CubeIDE
10.2.3 Mbed OS
10.2.4 First Mbed OS Project in Mbed Studio
10.3 Task and Thread
10.3.1 Task Working Principles
10.3.1.1 Task States
10.3.1.2 Task Priorities
10.3.1.3 Idle Task
10.3.2 Task in FreeRTOS
10.3.2.1 Task Setup and Task Functions
10.3.2.2 Task Usage Examples
10.3.3 Thread in Mbed OS
10.3.3.1 Thread Functions
10.3.3.2 Thread Usage Examples
10.4 Event
10.4.1 Event Working Principles
10.4.2 Event in FreeRTOS
10.4.2.1 Event Setup and Event Functions
10.4.2.2 Event Usage Examples
10.4.3 Event in Mbed OS
10.4.3.1 Event Functions
10.4.3.2 Event Usage Examples
10.5 Mutex and Semaphore
10.5.1 Mutex Working Principles
10.5.2 Semaphore Working Principles
10.5.3 Mutex and Semaphore in FreeRTOS
10.5.3.1 Mutex Setup and Mutex Functions
10.5.3.2 Mutex Usage Examples
10.5.3.3 Semaphore Setup and Semaphore Functions
10.5.3.4 Semaphore Usage Examples
10.5.4 Mutex and Semaphore in Mbed OS
10.5.4.1 Mutex Functions
10.5.4.2 Mutex Usage Examples
10.5.4.3 Semaphore Functions
10.5.4.4 Semaphore Usage Examples
10.6 Queue and Mail
10.6.1 Queue Working Principles
10.6.2 Mail Working Principles
10.6.3 Queue and Memory Pool in FreeRTOS
10.6.3.1 Queue Setup and Queue Functions
10.6.3.2 Queue Usage Examples
10.6.3.3 Memory Pool Setup and Memory Pool Functions
10.6.3.4 Memory Pool Usage Examples
10.6.4 Queue and Mail in Mbed OS
10.6.4.1 Queue Functions
10.6.4.2 Queue Usage Examples
10.6.4.3 Mail Functions
10.6.4.4 Mail Usage Examples
10.7 Software Timers in FreeRTOS
10.7.1 Software Timer Setup and Timer Functions
10.7.2 Software Timer Usage Examples
10.8 Memory Management in RTOS
10.8.1 Memory Management in FreeRTOS
10.8.2 Memory Management in Mbed OS
10.9 Application: RTOS-Based Implementation of the Robot Vacuum Cleaner
10.10 Summary of the Chapter
Problems
Reference
11 LCD, Touch Screen, and Graphical User Interface Formation
11.1 LCD
11.1.1 LCD Structure
11.1.2 LCD Working Principles
11.1.3 Connecting the LCD to an Image Source
11.1.4 LCD on the STM32F4 Board
11.2 Touch Screen
11.2.1 Touch Screen Working Principles
11.2.2 Touch Screen on the LCD of the STM32F4 Board
11.3 Hardware Modules in the STM32F4 Microcontroller for LCD and Touch Screen Control
11.3.1 LCD-TFT Display Controller
11.3.2 DMA2D
11.4 Setting Up the LCD on the STM32F4 Board
11.4.1 Setup for SPI-Based Usage
11.4.1.1 Setup via C Language
11.4.1.2 Setup via C++ Language
11.4.1.3 Setup via MicroPython
11.4.2 Setup for LTDC-Based Usage
11.4.2.1 Setup via C Language
11.4.2.2 Setup via C++ Language
11.5 Usage of the LCD on the STM32F4 Board
11.5.1 Usage of the LCD via SPI
11.5.1.1 Usage via C Language
11.5.1.2 Usage via C++ Language
11.5.1.3 Usage via MicroPython
11.5.2 Usage of the LCD via LTDC
11.5.2.1 Usage via C Language
11.5.2.2 Usage via C++ Language
11.6 Setting Up the Touch Screen on the LCD of STM32F4 Board
11.6.1 Setup via C Language
11.6.2 Setup via C++ Language
11.7 Usage of the Touch Screen on the LCD of STM32F4 Board
11.7.1 Usage via C Language
11.7.2 Usage via C++ Language
11.8 Graphical User Interface Formation via TouchGFX
11.8.1 Installing TouchGFX
11.8.2 Setting Up TouchGFX
11.8.3 Using TouchGFX
11.9 Application: Improving the Stand-Alone Remote Controller via GUI Formation and Touch Screen Usage
11.10 Summary of the Chapter
Problems
References
12 Introduction to Digital Signal Processing
12.1 About Digital Signals
12.1.1 Mathematical Definition of the Digital Signal
12.1.2 Representing the Digital Signal in an Embedded System
12.1.3 Forming an Actual Digital Signal from the STM32F4 Board
12.1.3.1 Data Acquisition via C Language
12.1.3.2 Data Acquisition via C++ Language
12.1.3.3 Data Acquisition via MicroPython
12.2 Transferring the Digital Signal Between the PC and STM32F4 Microcontroller
12.2.1 Setup in the STM32F4 Microcontroller Side
12.2.1.1 Setup via C Language
12.2.1.2 Setup via C++ Language
12.2.1.3 Setup via MicroPython
12.2.2 Setup in the PC Side
12.3 About Digital Systems
12.3.1 Mathematical Representation of the Digital System
12.3.2 Linear and Time-Invariant Systems
12.3.3 Representing the Digital System in an Embedded System
12.4 Digital Signals and LTI Systems in Complex Domain
12.4.1 The z-Transform
12.4.2 Discrete-Time Fourier Transform
12.5 Processing Analog Audio Signals on the STM32F4 Microcontroller
12.5.1 Acquiring the Audio Signal
12.5.2 Forming an Equalizer by Digital Filters
12.5.3 Feeding the Equalized Digital Signal to Output
12.5.4 Final Form of the Overall System
12.6 Summary of the Chapter
Problems
References
13 Introduction to Digital Control
13.1 About Digital Control
13.1.1 The Control Action
13.1.2 Representing the Digital Controller in an Embedded System
13.2 Transfer Function Based Control
13.2.1 Open-Loop Control
13.2.2 Closed-Loop Control
13.2.3 Designing a Controller
13.3 PID Controllers
13.3.1 General Structure
13.3.1.1 P Controller
13.3.1.2 PI Controller
13.3.1.3 PID Controller
13.3.2 PID Controller Design
13.3.3 Implementing the PID Controller on the STM32F4 Microcontroller
13.3.3.1 Implementation in C Language
13.3.3.2 Implementation in C++ Language
13.3.3.3 Implementation in MicroPython
13.4 PID Control of a DC Motor by the STM32F4 Microcontroller
13.4.1 DC Motor as the System to Be Controlled
13.4.2 Encoder as the Sensor
13.4.3 Speed Control of the DC Motor
13.5 Summary of the Chapter
Problems
Reference
14 Introduction to Digital Image Processing
14.1 About Digital Images
14.1.1 Mathematical Representation of the Digital Image
14.1.2 Grayscale and Color Images
14.1.3 Representing the Digital Image in the STM32F4 Microcontroller
14.1.3.1 Image Representation in C Language
14.1.3.2 Image Representation in C++ Language
14.1.3.3 Image Representation in MicroPython
14.2 Image Transfer Between the PC and STM32F4Microcontroller
14.2.1 Setup in the PC Side
14.2.2 Setup and Display in the STM32F4 Microcontroller Side
14.2.2.1 Setup and Display via C Language
14.2.2.2 Setup and Display via C++ Language
14.2.2.3 Setup and Display via MicroPython
14.3 Digital Camera as the Image Sensor
14.3.1 Working Principles of a Digital Camera
14.3.1.1 Optics and Image Sensor
14.3.1.2 Preprocessing
14.3.1.3 Camera Interface
14.3.1.4 Timing and Synchronization
14.3.1.5 Control Interface and Registers
14.3.2 Image Data Representation in Digital Cameras
14.3.2.1 Raw Form
14.3.2.2 Processed Form
14.3.2.3 Compressed Form
14.3.3 The OV7670 Camera Module
14.3.4 Setting Up the OV7670 Camera Module
14.3.4.1 Setup via C Language
14.3.4.2 Setup via C++ Language
14.3.4.3 Setup via MicroPython
14.4 Digital Camera Interface Module in the STM32F4 Microcontroller
14.4.1 Working Principles of the DCMI Module
14.4.2 Setting Up the DCMI Module
14.4.2.1 Setup via C Language
14.4.2.2 Setup via C++ Language
14.4.2.3 Setup via MicroPython
14.5 Image Acquisition via Digital Camera
14.5.1 Acquiring the Image
14.5.1.1 Image Acquisition via C Language
14.5.1.2 Image Acquisition via C++ Language
14.5.1.3 Image Acquisition via MicroPython
14.5.2 Displaying the Acquired Image on LCD
14.5.2.1 Display via C Language
14.5.2.2 Display via C++ Language
14.5.2.3 Display via MicroPython
14.5.3 Transferring the Acquired Image to PC
14.5.3.1 Image Transfer via C Language
14.5.3.2 Image Transfer via C++ Language
14.5.3.3 Image Transfer via MicroPython
14.5.4 Format Conversions
14.5.4.1 Format Conversion in C Language
14.5.4.2 Format Conversion in C++ Language
14.5.4.3 Format Conversion in MicroPython
14.6 Pixel-Based Digital Image Processing Operations
14.6.1 Obtaining the Negative Image
14.6.1.1 C Language
14.6.1.2 C++ Language
14.6.1.3 MicroPython
14.6.2 Intensity Transformation Applied to the Image
14.6.2.1 C Language
14.6.2.2 C++ Language
14.6.2.3 MicroPython
14.6.3 Thresholding the Image
14.6.3.1 C Language
14.6.3.2 C++ Language
14.6.3.3 MicroPython
14.7 Summary of the Chapter
Problems
References
15 Advanced Topics
15.1 Assembly Language Programming
15.1.1 Forming a Complete Assembly Code
15.1.2 Creating an Assembly Project in STM32CubeIDE
15.1.3 Inline Assembly in C Language
15.1.4 Inline Assembly in C++ Language
15.1.5 Inline Assembly in MicroPython
15.2 Customizing the MicroPython Firmware
15.2.1 Necessary Settings to Modify the MicroPython Firmware
15.2.2 Precompiling Scripts Usage
15.2.3 Frozen Bytecode Usage
15.2.4 Adding C Functions to MicroPython
15.3 Mbed Simulator
References
Index