Programming With STM32: Getting Started With the Nucleo Board and C/C++ Donald Norris - Download the ebook today and own the complete version
Programming With STM32: Getting Started With the Nucleo Board and C/C++ Donald Norris - Download the ebook today and own the complete version
https://ebookmass.com/product/programming-the-intel-galileo-getting-
started-with-the-arduino-compatible-development-board-christopher-
rush/
https://ebookmass.com/product/programming-arduino-getting-started-
with-sketches-tab-monk/
https://ebookmass.com/product/programming-arduino-getting-started-
with-sketches-third-edition-simon-monk/
https://ebookmass.com/product/programming-arduino-getting-started-
with-sketches-3rd-edition-simon-monk/
Programming the Photon: Getting Started with the Internet
of Things Rush Christopher.
https://ebookmass.com/product/programming-the-photon-getting-started-
with-the-internet-of-things-rush-christopher/
https://ebookmass.com/product/programming-the-raspberry-pi-third-
edition-getting-started-with-python-simon-monk/
https://ebookmass.com/product/programming-the-photon-getting-started-
with-the-internet-of-things-tab-christopher-rush/
https://ebookmass.com/product/getting-started-with-sql-and-databases-
managing-and-manipulating-data-with-sql-mark-simon/
https://ebookmass.com/product/getting-started-with-sql-and-databases-
managing-and-manipulating-data-with-sql-1st-edition-mark-simon/
Copyright © 2018 by McGraw-Hill Education. All rights reserved. Except as
permitted under the United States Copyright Act of 1976, no part of this
publication may be reproduced or distributed in any form or by any means, or
stored in a database or retrieval system, without the prior written permission of
the publisher.
ISBN: 978-1-26-003132-4
MHID: 1-26-003132-2
The material in this eBook also appears in the print version of this title: ISBN:
978-1-26-003131-7, MHID: 1-26-003131-4.
All trademarks are trademarks of their respective owners. Rather than put a
trademark symbol after every occurrence of a trademarked name, we use names
in an editorial fashion only, and to the benefit of the trademark owner, with no
intention of infringement of the trademark. Where such designations appear in
this book, they have been printed with initial caps.
This is a copyrighted work and McGraw-Hill Education and its licensors reserve
all rights in and to the work. Use of this work is subject to these terms. Except as
permitted under the Copyright Act of 1976 and the right to store and retrieve one
copy of the work, you may not decompile, disassemble, reverse engineer,
reproduce, modify, create derivative works based upon, transmit, distribute,
disseminate, sell, publish or sublicense the work or any part of it without
McGraw-Hill Education’s prior consent. You may use the work for your own
noncommercial and personal use; any other use of the work is strictly prohibited.
Your right to use the work may be terminated if you fail to comply with these
terms.
Peter enjoys cooking, fine wine, traveling, and spending quality time with his
family. His wife is my daughter, Shauna, and their child is my two-year-old
granddaughter, Evangeline.
Peter and I have spent many hours discussing many topics ranging from ancient
Greek artifacts to the latest technologies impacting modern society. I always
look forward to those interesting and challenging discussions.
CONTENTS AT A GLANCE
3 STM32CubeMX Application
6 Interrupts
7 Timers
9 Analog-to-Digital Conversion
Index
CONTENTS
Preface
3 STM32CubeMX Application
Pinout Tab
MCU Alternative Functions
Integrated Peripheral (IP) Tree Pane
Creating an Example Project using CubeMX
The main.c Code Listing
ARM Cortex Microcontroller Software Interface Standard (CMSIS)
CubeMX-Generated C Code
Compiling and Downloading the Project
Downloading the Hex Code
Summary
6 Interrupts
Interrupts
NVIC Specifications
Interrupt Process
External Interrupts
Interrupt Demonstration
Summary
7 Timers
STM Timer Peripherals
STM Timer Configuration
Update Event Calculation
Polled or Non-interrupt Blink LED Timer Demonstration
Test Run
Interrupt-Driven Blink LED Timer Demonstration
Test Run
Multi-rate Interrupt-Driven Blink LED Timer Demonstration
Test Run
Modification to the Multi-rate Program
Test Run
Summary
9 Analog-to-Digital Conversion
ADC Functions
ADC Module with HAL
ADC Conversion Modes
Channels, Groups, and Ranks
ADC Demonstration
ADC Demonstration Software
Summary
Microcomputer vs Microcontroller
I believe at the start of this book that it must make very clear the differences
between a microcomputer and a MCU. The reason for this distinction is very
simple: STM is a company that designs and manufacturers MCUs, not
microcomputers. I think my following definition of a MCU is as good as any
that I have read:
Right away, you can see from the definition that a MCU contains a
microprocessor which is sometimes referred to as a microcomputer. There also
must be both dynamic or volatile memory as well as nonvolatile or static
memory, where the latter holds any programs or scripts necessary to run the
microprocessor. Finally, there are always peripherals added to the design that
allow for the input and output of digital signals. There are often additional
peripherals such as timers, interrupt controllers, serial data ports, and a variety of
others depending upon what requirements the MCU must meet.
I discuss all the principal MCU components below to provide you with a solid
background to understand how a MCU functions. Most of the following
explanations are based on the voluminous amount of information provided by
STM on their microcontrollers. The reason behind STM providing such a large
amount of information is to allow engineers/software developers access to all the
data they need in order to incorporate STM products into original equipment
manufacturer (OEM) designs and products. This approach is fundamentally
different than the approach taken by suppliers of maker style boards and
products, such as the Arduino, Raspberry Pi, BeagleBone, and so forth. In the
case of the latter, board documentation is geared toward how to use a board in a
project. The STM data is extremely specific describing items such as the
nanosecond timing pulses between memory chips and processor buses. This is
exactly the reason why some of the STM MCU datasheets are over 1,100 pages
in length. Fortunately, the datasheet for the primary STM MCU I will be using in
this book is only 138 pages. I will provide later in this chapter the website where
you can download the datasheet.
The boards are named Nucleo-32, Nucleo-64, and Nucleo-144 from left to
right, respectively, as shown in Figure 1-1. The number in each name represents
the number of pins present in the MCU chip. Nucleo-64 is the principal board
used in this book.
Processor
The processor used in Nucleo-32 and Nucleo-64 boards is the ARM Cortex M-4
32-bit processor. It too has a lengthy 278-page user guide available from
infocenter.arm.com/help/topic/com.arm.doc.dui0553a/DUI0553A_cortex_m4_dgug.pdf
The actual processor circuitry is part of the STM MCU because STM has
purchased intellectual property (IP) rights from the ARM Corporation in order to
integrate it into its chips. However, for all practical purposes, the ARM
processor is programmed using the tools and techniques promulgated by the
ARM Corporation to support its processor IP. This distinction is of no
consequence in our case because the software tools to be used for the book
projects have all been carefully crafted and tested to work seamlessly together by
STM. Any license issues have already been resolved without bothering the end
user.
The following list contains some of the important specifications for the
Cortex M-4 processor for interested readers:
• Full-featured ARMv7-M instruction set, optimized for embedded
applications
• Floating point unit (FPU)
• Low-power 32-bit processor
• Memory protection unit (MPU)
• Nested vector interrupt controller (NVIC)
• Trace, breakpoint, and JTAG capabilities
• Advanced Microcontroller Bus Architecture (AMBA)
• Advanced High-Performance Bus (AHB5, AHB-Lite)
There are many more features to the Cortex M-4 processor as the 278-page
user guide would suggest. I would also recommend Joseph Yiu’s book, The
Definitive Guide to ARM® Cortex®-M3 and Cortex®-M4 Processors, Third
Edition, to readers who really want to delve into this processor to a great depth.
Figure 1-2 is a block diagram of the Cortex M-4 processor showing all of the
listed items and more.
Figure 1-2 ARM Cortex M-4 block diagram.
Memory
The Cortex M-4 processor uses a Harvard architecture. This means that program
instructions are stored and retrieved from a memory separate and distinct from
the memory that holds data. The other common computer architecture is named
von Neumann in which instructions and data share a common memory. MCUs
have very limited memory and take advantage of the speed-up available by using
concurrent instruction and data access. Additionally, having separate memories
means that the processor is no longer constrained to the same sized data widths.
This means instructions can be fetched and executed in 4-byte chunks or 32 bits,
while data can be simultaneously handled with 1-byte or 8-bit chunks, thus
speeding up the overall throughput to and from the processor and memory.
Another advantage the Harvard architecture has over the von Neumann form is
that instruction prefetches can now be done in parallel with regular instruction
executions, thus further speeding up the overall system performance. Finally,
concurrent instruction and data access eliminates the need for data caches, which
are typically used in von Neumann machines. This further reduces system
complexity and power consumption.
The Nucleo-64 board used in this book is the STM MCU, model number
STM32F302R8. This chip has a 64-KB flash memory and a 16-KB static
random access memory (SRAM). Yes, those are kilobytes, not mega- or
gigabytes. You cannot expect to create any graphical programs that run in this
limited memory space. Microcontroller programs are truly a throwback to the
earliest days of computing where memory was very limited and developers had
to use every available byte to store and execute programs. Having mentioned the
scarce memory resources, you will be able to use a variety of modern-day
graphic-based programs to develop the MCU program, but they will run on a
PC. The compiled and optimized binary code will be downloaded into the MCU
from the PC.
It turns out that 64 KB is plenty of space to run fairly large programs because
the C/C++ cross-compiler used for this book’s projects produces optimize code,
eliminating all but the essential instructions needed for the program. The 16-KB
SRAM size is more than adequate for the dynamic memory requirements to
support a maximum 64-KB sized program. The actual memory is integrated onto
Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
Other documents randomly have
different content
XXXIV. The Same
The Opinion of Octavius
XXXV.
Fanks
CONTENTS
CONTENTS
A TRAITOR IN LONDON
By Fergus Hume
CONTENTS
CUPID IN LEADING
I.
STRINGS.
A SHOT IN THE
II. THE GIRL HE LEFT
DARKNESS. XV.
THE NAME OF THE BEHIND HIM.
III. THE UNEXPECTED
VICTIM. XVI.
A STRANGE PIECE OF HAPPENS.
IV. XVII. CHECKMATED.
EVIDENCE.
VAN ZWIETEN SHOWS XVIII. EXIT VAN ZWIETEN.
V.
HIS TEETH. XIX. A TERRIBLE LETTER.
WHAT MR. SCARSE XX. ON THE TRACK.
VI.
ADMITTED. XXI. IN SOUTH AFRICA.
VII. AUNT JUDY. XXII. AT THE FRONT.
VIII. BAD NEWS. XXIII. A DUTCH LOCHINVAR.
MRS. ST. LEGER IS AN UNEXPECTED
IX. XXIV.
DISCREET. MEETING.
X. THE MASS MEETING. XXV. BESIEGED.
A STARTLING XXVI. IN CAPTIVITY.
XI.
DISCOVERY. XXVII. NEMESIS.
XII. A STORY OF THE PAST. XXVIII. CALM AFTER STORM.
XIII. THE END OF THE STORY.
WHAT VAN ZWIETEN
XIV.
KNEW.
IN QUEER STREET
By Fergus Hume
CONTENTS
CHAPTER
XI. MACBETH'S BANQUET
THE BOARDING-
I. XII. CUPID'S GARDEN
HOUSE
XIII. DANGER
OLD SCHOOL-
II. XIV. AT BAY
FELLOWS
III. MAN PROPOSES XV. A FRIEND IN NEED
IV. THE ADVERTISEMENT XVI. EXPLANATIONS
V. THE NEXT STEP XVII. BLACKMAIL
VI. SEEKING TROUBLE XVIII. HENCH'S DIPLOMACY
AN AMAZING XIX. A DENIAL
VII. REAPING THE
DISCOVERY XX.
VIII. FAMILY HISTORY WHIRLWIND
IX. GWEN THE SUNSHINE OR
XXI.
LIFE
X. VANE'S AUNT
THE BEGINNING OF A
I. XIV. THE FAMILY LAWYER
MYSTERY
XV. A STARTLING LETTER
THE UNEXPECTED
II. XVI. RECOGNITION
HAPPENS
III. ANOTHER MYSTERY XVII. DISGRACE
IV. A FAMILY HISTORY LADY CHARVINGTON'S
XVIII.
ACCUSATIONS
MRS. WALKER'S
V. XIX. MR. HALE EXPLAINS
OPINION
PURPLE AND FINE JOURNEYS END IN LOVERS'
VI. XX.
LINEN MEETING
VII. AFTER MIDNIGHT XXI. TWO INTERVIEWS
VIII. UNDER A CLOUD XXII. THE PLOT
IX. TWO GIRLS XXIII. ONE PART OF THE TRUTH
X. THE DEUS EX MACHINA ANOTHER PART OF THE
XXIV.
TRUTH
XI. THE SEAMY SIDE
XXV. REVENGE
XII. A COUNTERPLOT
XXVI. THE END OF IT ALL
XIII. MRS. WALKER'S VISIT
THE PURPLE FERN
By Fergus Hume
CONTENTS
PROLOGUE
THE FIRST SCENE: AT CASTERWELL.
CHAPTER.
I. DAVID AND JONATHAN.
II. THE SEALED LETTER.
III. AT THE MANOR HOUSE.
IV. A QUEER COINCIDENCE.
V. THE SUSPICIONS OF LAURENCE MALLOW.
VI. THE REVEREND MANNERS BROCK.
VII. MARGERY.
VIII. JEPHTHAH'S DAUGHTER.
IX. "TWENTY-ONE."
X. A PRE-NUPTIAL CONTRACT.
XI. THE NEW MAID.
XII. "WEDDING-BELLS."
THE SECOND SCENE: AT SANDBEACH.
I. "THE HAPPY PAIR."
II. "THE BROOCH."
III. "CLARA'S LETTER."
IV. "MORE MYSTERY."
THE THIRD SCENE IN LONDON.
I. "MYSTERIOUS MRS. ARNE."
II. "MRS. PURCELL."
III. "A PRIVATE INQUIRY AGENT."
IV. "ONE OF US."
V. "MADAME DEATH-IN-LIFE."
VI. "ANOTHER LINK."
VII. "AN UNEXPECTED MEETING."
VIII. "THE LIGHT-HAIRED MAN."
IX. "MAN PROPOSES."
X. "WOMAN DISPOSES."
THE FOURTH SCENE: IN FLORENCE.
I. "ON THE LONG TRAIL."
II. "ONE PORTION OF THE CONSPIRACY."
III. THE SANDAL-WOOD CHEST.
IV. "ANOTHER PORTION OF THE CONSPIRACY."
THE FIFTH SCENE: IN LONDON.
I. "THE MISSING MAN."
II. "MONSIEUR ROUGE IS CONFIDENTIAL."
III. "A TERRIBLE ADVENTURE."
IV. "THE ISHMAELS OF HUMANITY."
THE SIXTH SCENE: AT CASTERWELL.
I. "AN UNEXPECTED ARRIVAL."
II. "THE PENANCE OF MARGERY."
III. "MR. BROCK AND THE LETTER."
IV. "THE TREASURES AT KIKAT."
V. "LET THE DEAD PAST BURY ITS DEAD."
VI. "MR. BROCK'S ADDENDA."
VII. "THE CIPHER DIARY."
VIII. "A ROGUE'S MEMOIRS."
EPILOGUE
THE GATES OF DAWN
By Fergus Hume
CONTENTS
JONAH'S LUCK
By Fergus Hume
CONTENTS
AN UNEXPECTED
CHAP. XIV.
ARRIVAL
THE ADVENTURE OF
I. XV. A FRIEND IN NEED
THE INN
XVI. M. GOWRIE'S PLOTTING
II. A RECOGNITION
XVII. MAUD'S INHERITANCE
CIRCUMSTANTIAL
III. XVIII. A SURPRISING DEFENCE
EVIDENCE
IV. WHAT HAPPENED NEXT XIX. MRS. MOUNTFORD'S
ACCUSATION
V. HUE AND CRY
XX. AT THE "MARSH INN"
VI. THE CARAVAN
XXI. ON BOARD THE YACHT
VII. KIND'S OPINIONS
XXII. ANOTHER MYSTERY
VIII. MISS MAUD TEDDER
XXIII. AN EXPLANATION
IX. THE SOLICITOR
XXIV. STARTLING NEWS
X. THE INQUEST
XXV. THE CAPTAIN'S STORY
XI. LOVERS
THE BEGINNING OF THE
XII. THE STRANGE WORD XXVI.
END
XIII. A MEXICAN BEAUTY
XXVII. THE END
THE PEACOCK OF JEWELS
By Fergus Hume
CONTENTS
THE ROTHERHITHE
I.
CRIME. XII. AN INDIAN CLIENT.
II. AT THE VICARAGE. XIII. AN UNEXPECTED VISITOR.
III. A STORY OF THE PAST. XIV. FACE TO FACE.
AN UNEXPECTED XV. THE BLACK BAG.
IV.
VISITOR. MISS INDERWICK'S
XVI.
V. THE LETTER. EXCURSION.
THE BOARDING- XVII. THE SECRET.
VI.
HOUSE. XVIII. THE TREASURE HUNT.
VII. YULETIDE. XIX. AT DAWN.
VIII. AN EXPLANATION. XX. WHO IS GUILTY?
IX. ANOTHER TRAIL. XXI. THE TRUTH.
X. MR. SORLEY'S JEWELS. XXII. CALM AFTER STORM.
XI. JOTTY.
CONTENTS
Updated editions will replace the previous one—the old editions will
be renamed.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookmass.com