Beställningsvara. Skickas inom 5-8 vardagar. Fri frakt för medlemmar vid köp för minst 249 kr.
Many everyday objects have become embedded, connected and even autonomous. The engineers and technicians who develop them must have skills in both computer science and electronics.Drawing on some 20 years of experience in the field of hardware and embedded computing, Programming of Embedded Systems analyzes how physical objects can interact with microcontrollers. It presents the fundamental principles of programming and code structuring. Although based on a specific family (STM32) of microcontrollers, the various chapters outline general concepts applicable to any microcontroller. They analyze the mechanisms that govern exchanges between a computer program and a hardware component of the embedded object.Each chapter details the programming of peripheral units and ends with an example using a common application for managing the heating of a home equipped with a photovoltaic installation to illustrate implementation in the programming language C.
Vincent Mahout is Lecturer at INSA Toulouse, France, where he teaches automation and hardware and embedded computing.Thierry Rocacher is Associate Professor of Electrical Engineering at INSA Toulouse, France, where he teaches electronics and embedded computing.Guillaume Auriol is Associate Professor of Electrical Engineering at INSA Toulouse, France, where he teaches electronics and embedded computing.
Preface xiChapter 1 Aims, Context and a Guiding Thread Example 11.1. Aims of this book 11.2 What this book contains and what it does not 21.3. About the code examples 31.4. Choosing your μcontroller: the STM32 family 31.4.1. Criteria when choosing a μcontroller 41.4.2. STM32 family 51.4.3. STM32F10x line 61.5. Guiding thread example 81.5.1. Context: photovoltaic self-consumption installation 81.5.2. System: optimization of electric heating in a photovoltaic self-consumption household 101.5.3. Summary of the peripherals seen in the guiding thread example 13Chapter 2 General Programming Principles 152.1. Pointers and registers 152.1.1. “Simple” variables 152.1.2. Pointer to a variable 162.1.3. Using pointers to pass arguments to functions 182.1.4. When to use a pointer? 202.1.5. Function pointers 212.2. C language structure and usage in the STM 32 222.2.1. Structured type organization 222.2.2. Accessing registers via a structure 242.3. Case of nested structures 252.4. Masks usage 272.4.1. General considerations 282.4.2. Masks for setting bits to 1 292.4.3. Masks for setting bits to 0 302.4.4. Bit inversion 312.4.5. Extension and generalization to bit field assignment 312.5. Code structuring and the concept of drivers 332.6. Interrupt routines 362.6.1. Handler routines concepts 362.6.2. Interrupt routine implementation 372.6.3. Redirection via dynamic programming 39Chapter 3 General STM32F10x Hardware Considerations 433.1. Global STM32 architecture 433.2. Cortex-M3 components 443.3. Clock trees and RCC units 473.3.1. Generation of primary clocks 473.3.2. Generation of secondary clocks 493.3.3. RCC unit programming 513.3.4. RCC unit configuration coding example 553.4 Watchdogs 573.4.1 Independent watchdogs 583.4.2 Windowed watchdogs 59Chapter 4 Binary Inputs/Outputs (I/O): Parallel Ports 614.1. Concept of I/O ports 614.2. Electronic aspect 624.2.1. Global architecture 634.2.2. Input configuration 654.2.3. Output configuration 664.3. STM32 GPIOs 674.3.1. Configuration registers 694.3.2. Access registers 704.4. Example 734.4.1. Proposed solution 754.4.2. Comments 804.5. Unaddressed points regarding GPIOs 81Chapter 5 Interrupt and DMA Management 835.1. General exceptions and particular interrupts 835.2. Resets and interrupt vector tables 845.2.1. Stack pointers and program counters 845.2.2. IVT contents 855.3. Principle of redirection and the role of the NVIC 885.3.1. Nvic 885.3.2. Conditions for an interrupt to be accepted 905.3.3. Priority management 925.3.4. Redirection process steps 965.4. Case of external interrupt inputs 965.4.1. AFIO and EXTI peripherals 975.4.2. NVIC level 985.4.3. GPIO and AFIO levels 995.4.4. EXTI level 1025.5. Guiding thread example: treating an EXTI exception 1035.5.1. Problem to solve 1035.5.2. Proposed solution 1035.6. Direct memory access 1055.6.1. Generalities 1055.6.2. DMA on the STM32F10x 1065.7. Guiding thread example: case of DMA programming 1115.7.1. UART configuration 1125.7.2. DMA configuration 1125.7.3. Program structure 112Chapter 6 Timers 1156.1. General information on counters or Timers 1156.1.1. Basic principle 1166.1.2. Timer units in the STM32F10x 1166.1.3. Different types of Timers 1176.2. Operating modes 1186.2.1. General structure of a Timer 1196.2.2. Core block: overflow, events and frequency 1206.2.3. Capture/Compare block 1256.2.4. Trigger controller block and encoder interface 1296.2.5. Master mode 1396.3. An additional Timer: the SysTick 1416.4. Guiding thread example 1436.4.1. Case study: a control knob 1436.4.2. Code extract 143Chapter 7 Pulse-Width Modulation (PWM) 1457.1. Generalities on PWM-type signals 1457.1.1. Definition 1457.1.2. Use in information transmission 1477.1.3. Use in digital-to-analog conversion 1487.2. Implementation of PWM in an STM32F10x µcontroller 1547.2.1. Basic operation 1547.2.2. Configuration and options 1567.3. Guiding thread example 1607.3.1. First possible solution 1607.3.2. Second adopted solution 1607.3.3. Interrupt configuration 1607.3.4. The PWM configuration itself 1617.3.5. The GPIO configuration 1617.3.6. Code excerpt 161Chapter 8. Analog to Digital Converter 1658.1. Generalities and operating principles 1658.1.1. Role and definitions 1658.1.2. Successive-approximation ADC 1688.1.3. Variable voltage measurement 1698.1.4. Multi-channel ADC 1728.1.5 Overview of the ADC timings 1738.2. ADC in the STM32F10x 1748.2.1 Simplified architecture of the ADC 1748.2.2. ADC functional modes 1818.2.3. DMA with ADC 1858.3. Application: the power analyzer 1868.3.1 Determining the sampling duration T s 1868.3.2. Code excerpt for configuration 187Chapter 9. Some Communication Buses 1919.1. Introduction 1919.2. UART units 1939.2.1. Generalities 1939.2.2. Reading/writing techniques 1959.2.3. UART configuration on the STM32F10x 1979.3. SPI units 2039.3.1. Generalities 2039.3.2. Shift register-based read/write techniques 2059.3.3. SPI configuration on the STM32F10x 2099.4. I 2 C bus 2139.4.1. Generalities 2139.4.2. Electrical topology of the I 2 C bus 2159.4.3. Principle and protocol 2169.4.4. Reading/writing techniques 2209.4.5. I 2 C configuration on the STM32F10x 2249.5. Guiding thread example 2339.5.1. UART reception in interrupt mode 2339.5.2. Temperature measurement via the I 2 C bus and DMA 234Chapter 10. STM32 Power Management 24110.1. Introduction 24110.2. Domains of the µcontroller 24210.2.1 1.8V Domain 24210.2.2 V DD Domain 24410.2.3 Backup Domain 24410.2.4 V DDA Domain 24510.3. Reset on STM 32 24510.3.1 System Reset 24510.3.2 Power Reset 24710.3.3 Backup Domain Reset 24710.3.4. Reset flags (RCC_CSR) management 24710.3.5. STM32F10x reset summary 24810.4. RTC registers 24910.4.1 Secure access to the Backup Domain 25010.4.2. RCC_BDCR registers 25010.4.3. RTC register structure 25110.4.4. Reading/writing RTC registers 25210.5. Low Power modes 25410.5.1. Event and interrupt 25410.5.2. Key bits for Low Power modes 25510.5.3. Sleep mode 25810.5.4. Stop mode 25910.5.5. Standby mode 26010.6. Software architecture and using Low Power modes 26110.6.1. Classical software architecture 26110.6.2. Sleeping in main(), WFI instruction 26210.6.3. Automatic sleep upon interrupt exit 26210.6.4. Sleeping in main(), WFE instruction 26410.6.5. Standby mode on RTC alarm 26410.7. Guiding thread example for Low Power mode 26410.7.1. Problem to solve 26410.7.2. Proposed solution 265Appendix 271References 283Index 285