Microcontroller Engineering with MSP432: Fundamentals and Applications, 1st Edition (Hardback) book cover

Microcontroller Engineering with MSP432

Fundamentals and Applications, 1st Edition

By Ying Bai

CRC Press

818 pages | 327 B/W Illus.

Purchasing Options:$ = USD
Hardback: 9781498772983
pub: 2016-10-20
SAVE ~$19.39
$96.95
$77.56
x
eBook (VitalSource) : 9781315367101
pub: 2016-11-03
from $48.48


FREE Standard Shipping!

Description

This book aims to develop professional and practical microcontroller applications in the ARM-MDK environment with Texas Instruments MSP432P401R LaunchPad kits. It introduces ARM Cortex-M4 MCU by highlighting the most important elements, including: registers, pipelines, memory, and I/O ports. With the updated MSP432P401R Evaluation Board (EVB), MSP-EXP432P401R, this MCU provides various control functions with multiple peripherals to enable users to develop and build various modern control projects with rich control strategies. Micro-controller programming is approached with basic and straightforward programming codes to reduce learning curves, and furthermore to enable students to build embedded applications in more efficient and interesting ways. For authentic examples, 37 Class programming projects are built into the book that use MSP432P401R MCU. Additionally, approximately 40 Lab programming projects with MSP432P401R MCU are included to be assigned as homework.

Reviews

"This textbook provides a systemic, complete introduction and discussion about MSP432 MCU components and implementations, including most popular peripherals, with over 70 projects. It supplies plenty of learning and teaching materials in each chapter with homework assignments, exercises, class projects, lab projects, and MS PPT slides, which are convenient for college students and instructors.

This is the first textbook that provides such complete and up-to-date materials on MSP432 MCU for college students and professional programmers, which provides a shortcut between what to learn in school and what fundamentals are needed in the market in the related technical fields.

In short, this is a textbook that provides the up-to-date and complete learning materials that can help students learn this kind of technical knowledge in a practical way and be better prepared for the application market fields in engineering or information technology, in which micro-computers and micro-controllers are widely used."

—Daoxi Xiu, NC Administrative Office of the Courts, USA

"Clear and concise with detailed, well thought out topics, applications, and graphics. Dr. Bai provides a very detailed explanation of the hardware and its application, which aids to a rapid understanding of the MPS432 microcontroller. The use of the MPS432P401R MCU-based EVB as a common core for the development of software and hardware applications provides a stable platform with consistent results in the classroom."

— Thomas Stout, Tidewater Community College, Virginia, USA

Table of Contents

Contents

Preface………………………………………………………………………………………………………………………….. xix

Acknowledgments……………………………………………………………………………………………………….. xxi

Author…………………………………………………………………………………………………………………………xxiii

Trademarks and references………………………………………………………………………………………….. xxv

Chapter 1 Introduction to microcontrollers and this book………………………………………….1

1.1 Microcontroller configuration and structure…………………………………………………………..1

1.2 ARM® Cortex®-M4 microcontroller system……………………………………………………………..3

1.3 MSP432P401R microcontroller and its development tools and kits………………………….4

1.4 Outstanding features about this book……………………………………………………………………..4

1.5 Who this book is for………………………………………………………………………………………………..5

1.6 What this book covers……………………………………………………………………………………………..5

1.7 How this book is organized and how to use this book……………………………………………7

1.8 How to use the source code and sample projects…………………………………………………….7

1.9 Instructors and customers supports……………………………………………………………………… 10

Chapter 2 MSP432 microcontroller architectures……………………………………………………….11

2.1 Overview……………………………………………………………………………………………………………… 11

2.2 Introduction to ARM• Cortex•-M4 MCU……………………………………………………………… 12

2.2.1 Architecture of ARM• Cortex•-M4 MCU…………………………………………………. 15

2.2.1.1 ARM• MCU architecture block diagram…………………………………… 15

2.2.1.2 Architecture of the ARM• Cortex•-M4 core (CPU)……………………. 17

2.2.1.3 Architecture of the floating-point registers………………………………..22

2.3 Introduction to MSP-432™ MCU family member—MSP432P401R…………………………25

2.3.1 MSP432P401R microcontroller overview……………………………………………………25

2.3.2 MSP432P401R microcontroller on-chip memory map………………………………..26

2.3.3 System peripherals……………………………………………………………………………………29

2.3.3.1 On-chip peripherals…………………………………………………………………..29

2.3.3.2 Interfaces to external parallel and serial peripherals…………………. 31

2.3.4 MSP432P401R microcontroller GPIO modules………………………………………….. 32

2.3.4.1 MSP432P401R GPIO ports architecture……………………………………… 32

2.3.4.2 General digital I/O function control…………………………………………..33

2.3.4.3 PM control………………………………………………………………………………….40

2.3.4.4 Comparison between the digital I/O function control

and PM control…………………………………………………………………………..42

2.3.4.5 Initialization and configuration of GPIO ports…………………………..43

2.3.5 MSP432P401R microcontroller system controls………………………………………….44

2.3.5.1 MCU system reset control………………………………………………………….45

2.3.5.2 Power supply system (PSS)…………………………………………………………48

2.3.5.3 Power control manager (PCM)…………………………………………………..50

2.3.5.4 System clock control…………………………………………………………………..53

2.3.5.5 System controller (SYSCTL)………………………………………………………..65

2.4 Introduction to MSP432P401R LaunchPad™ MSP-EXP432P401R evaluation board……65

2.4.1 Onboard hardware configurations…………………………………………………………… 70

2.4.2 GPIO pins configurations on booster pack interface connectors (J1~J4)…….. 70

2.5 Introduction to EduBASE ARM• trainer………………………………………………………………..72

2.6 Chapter summary…………………………………………………………………………………………………73

Chapter 3 MSP432 microcontroller development kits………………………………………………..79

3.1 Overview………………………………………………………………………………………………………………79

3.2 Entire MSP432P401R-based development system…………………………………………………..80

3.3 Download and install development suite and specified firmware…………………………82

3.4 Introduction to the IDE: Keil• MDK μVersion5………………………………………………………82

3.4.1 Keil• MDK-ARM• for the MDK-Cortex-M family……………………………………..84

3.4.2 General development flow with MDK-ARM•…………………………………………… 85

3.4.3 Functions of the Keil• MDK-ARM• μVersion•5 GUI………………………………… 87

3.4.3.1 File menu……………………………………………………………………………………89

3.4.3.2 Edit and view menus………………………………………………………………….90

3.4.3.3 Project menu………………………………………………………………………………92

3.4.3.4 Flash menu………………………………………………………………………………. 111

3.4.3.5 Debug menu……………………………………………………………………………. 112

3.4.3.6 Peripherals menu…………………………………………………………………….. 113

3.4.3.7 Tools menu………………………………………………………………………………. 113

3.4.3.8 Software version control system (SVCS) menu………………………… 115

3.4.3.9 Window menu…………………………………………………………………………. 116

3.4.3.10 Help menu……………………………………………………………………………….. 116

3.5 Embedded software development procedure……………………………………………………… 117

3.6 ARM•-MDK μVision5 debugger and debug process…………………………………………… 117

3.6.1 ARM• μVision5 debug architecture………………………………………………………… 119

3.6.2 ARM• debug adaptor and debug adaptor driver……………………………………. 120

3.6.3 MSP432™ Family Launchpad™ debug adaptor and debug

adaptor driver………………………………………………………………………………………….122

3.6.4 ARM• μVersion5 debug process………………………………………………………………122

3.7 MSP432™ family software suite………………………………………………………………………….. 123

3.7.1 MSPWare for MSP432™ series software package……………………………………. 125

3.7.1.1 Peripheral driver library (driverlib)………………………………………….. 126

3.7.1.2 Boot loader………………………………………………………………………………. 126

3.7.1.3 Code examples………………………………………………………………………… 127

3.8 MSP432™ series CMSIS support…………………………………………………………………………. 127

3.9 Chapter summary………………………………………………………………………………………………. 128

Chapter 4 ARM® microcontroller software and instruction set……………………………….131

4.1 Overview……………………………………………………………………………………………………………. 131

4.2 Introduction to ARM• Cortex•-M4 software development structure………………….. 132

4.3 ARM• Cortex•-M4 assembly instruction set……………………………………………………….. 133

4.3.1 ARM• Cortex•-M4 assembly language syntax……………………………………….. 134

4.3.2 ARM• Cortex•-M4 pseudo instructions…………………………………………………. 136

4.3.3 ARM• Cortex•-M4 addressing modes……………………………………………………. 137

4.3.3.1 Immediate offset addressing mode………………………………………….. 137

4.3.3.2 Register offset addressing mode……………………………………………… 139

4.3.3.3 PC-relative addressing mode…………………………………………………… 141

4.3.3.4 Load and store multiple registers addressing mode………………… 142

4.3.3.5 PUSH and POP register addressing mode……………………………….. 145

4.3.3.6 Load and store register exclusive addressing mode…………………. 145

4.3.3.7 Inherent addressing mode……………………………………………………….. 146

4.3.3.8 Addressing mode summary……………………………………………………. 147

4.3.4 ARM• Cortex•-M4 instruction set categories…………………………………………. 147

4.3.4.1 Data moving instructions………………………………………………………… 147

4.3.4.2 Arithmetic instructions…………………………………………………………… 149

4.3.4.3 Logic instructions……………………………………………………………………. 152

4.3.4.4 Shift and rotate instructions……………………………………………………. 153

4.3.4.5 Data conversion instructions…………………………………………………… 155

4.3.4.6 Bit field processing instructions………………………………………………. 157

4.3.4.7 Compare and test instructions…………………………………………………. 161

4.3.4.8 Program flow control instructions…………………………………………… 162

4.3.4.9 Saturation instructions…………………………………………………………….. 166

4.3.4.10 Exception-related instructions…………………………………………………. 168

4.3.4.11 Sleep mode instructions………………………………………………………….. 169

4.3.4.12 Memory barrier instructions……………………………………………………. 169

4.3.4.13 Miscellaneous instructions……………………………………………………… 170

4.4 ARM• Cortex•-M4 software development procedures……………………………………….. 170

4.5 Using C language to develop MSP432P401R microcontroller applications………….. 172

4.5.1 Standard data types used in intrinsic functions…………………………………….. 172

4.5.2 CMSIS core-specific intrinsic functions………………………………………………….. 174

4.5.3 Keil• ARM• compiler-specific intrinsic functions…………………………………… 177

4.5.4 Inline assembler……………………………………………………………………………………… 177

4.5.5 Naming convention and definition in C programming developments……….. 181

4.5.6 MSPWare peripheral driver library………………………………………………………… 182

4.5.6.1 Programming models……………………………………………………………… 182

4.5.6.2 DRA model……………………………………………………………………………… 182

4.5.6.3 Peripheral driver library and API functions…………………………….. 190

4.5.6.4 Comparison between two programming models……………………. 199

4.5.6.5 Combined programming model example…………………………………200

4.6 Chapter summary……………………………………………………………………………………………….204

Chapter 5 MSP432 microcontroller interrupts and exceptions………………………………..221

5.1 Overview……………………………………………………………………………………………………………. 221

5.2 Exceptions and interrupts in the ARMR CortexR-M4 MCU system………………………222

5.2.1 Exception and interrupt types…………………………………………………………………223

5.2.2 Exceptions and interrupts management…………………………………………………. 224

5.2.3 Exception and interrupt processing…………………………………………………………228

5.2.3.1 Exception and interrupt inputs and pending status…………………229

5.2.3.2 Exception and interrupt vector table………………………………………..230

5.2.3.3 Definitions of the priority levels………………………………………………. 231

5.3 Exceptions and interrupts in the MSP432P401R microcontroller system………………233

5.3.1 Local interrupts configurations and controls for GPIO pins……………………236

5.3.2 Local interrupts configurations and controls for GPIO ports………………….. 237

5.3.2.1 NVIC interrupt priority level registers……………………………………..238

5.3.2.2 NVIC Interrupt set enable registers (ISERs)…………………………….. 242

5.3.3 Global interrupts configurations and controls………………………………………… 243

5.3.4 GPIO interrupt handling and processing procedure………………………………. 244

5.4 Developing GPIO port interrupt projects to handle GPIO interrupts………………….. 245

5.4.1 Using DRA programing model to handle GPIO interrupts…………………….. 245

5.4.1.1 Create a new project DRAInt and the header file…………………….. 246

5.4.1.2 Create a new C code file DRAInt and add it into the project……. 247

5.4.1.3 Set up environment to compile and run the project…………………. 249

5.4.2 Using CMSIS-core macros for NVIC registers to handle

GPIO interrupts……………………………………………………………………………………. 249

5.4.2.1 Popular data structures defined in the MSP432P401R

header file…………………………………………………………………………………250

5.4.2.2 IRQ numbers defined in the MSPWare system header file………. 252

5.4.2.3 NVIC macros defined in the MSPWare system header files……..255

5.4.2.4 NVIC structure defined in the CMSIS-core header file…………….256

5.4.2.5 Building sample project to use CMSIS-core macros for

NVIC to handle interrupts……………………………………………………….258

5.4.2.6 Create a new project NVICInt and add the C code file…………….. 259

5.4.3 Using MSPPDL API functions to handle GPIO interrupts………………………. 261

5.4.3.1 NVIC API functions defined in the MSPPDL…………………………… 261

5.4.3.2 GPIO interrupt-related API functions in the MSPPDL…………….. 262

5.4.3.3 Building sample project to use API functions to handle

interrupts…………………………………………………………………………………264

5.4.3.4 Create a new project SDInt and add the C code file………………….265

5.4.3.5 Configure environments and run the project…………………………… 266

5.4.4 Using CMSIS-core access functions to handle GPIO interrupts………………. 268

5.4.4.1 Building a sample project to use CMSIS-core functions

to handle interrupts…………………………………………………………………. 269

5.4.4.2 Create a new project CMSISInt and add the C code file…………… 270

5.4.4.3 Configure environments and run the project…………………………… 272

5.5 Comparison among four interrupt programing methods…………………………………… 272

5.6 Chapter summary………………………………………………………………………………………………. 273

Chapter 6 ARM® and MSP432™ MCU memory system……………………………………………289

6.1 Overview……………………………………………………………………………………………………………. 289

6.2 Memory architecture in the MSP432P401R MCU system……………………………………..290

6.3 Static random-access memory (SRAM)……………………………………………………………….. 291

6.3.1 SRAM memory map in the MSP432P401R MCU system…………………………. 292

6.3.2 SRAM control and status registers…………………………………………………………. 293

6.3.2.1 SRAM size (SYS_SRAM_SIZE) register…………………………………… 293

6.3.2.2 SRAM bank enable (SYS_SRAM_BANKEN) register………………. 293

6.3.2.3 SRAM bank retention control register

(SYS_SRAM_BANKRET)…………………………………………………………. 294

6.3.3 Bit-band operations………………………………………………………………………………… 297

6.3.3.1 Mapping relationship between the bit-band region

and bit-band alias region…………………………………………………………. 298

6.3.3.2 Advantages of using the bit-band operations…………………………… 298

6.3.3.3 Illustration example of using bit-band alias addresses……………..300

6.3.3.4 Bit-band operations for different data sizes………………………………302

6.3.3.5 Bit-band operations built in C programs…………………………………..302

6.4 Internal ROM……………………………………………………………………………………………………….303

6.4.1 Bootstrap loader (BSL)……………………………………………………………………………..304

6.4.2 MSPWare peripheral driver library…………………………………………………………306

6.5 Flash memory………………………………………………………………………………………………………308

6.5.1 Basic operational components of the flash memory………………………………… 310

6.5.1.1 Flash controller clocking………………………………………………………….. 310

6.5.1.2 Flash controller address mapping……………………………………………. 310

6.5.1.3 Flash controller access privileges…………………………………………….. 311

6.5.2 Operational modes of the flash memory…………………………………………………. 312

6.5.2.1 Flash memory read mode and features……………………………………. 312

6.5.2.2 Flash memory program (write) mode………………………………………. 320

6.5.2.3 Flash memory erase mode………………………………………………………..330

6.5.2.4 Flash memory Write-Erase protection………………………………………333

6.5.3 Flash memory interrupt handling…………………………………………………………..335

6.5.4 Low-frequency active and low-frequency LPM0 modes support…………….336

6.5.5 Flash controller benchmarking features…………………………………………………. 337

6.5.6 Recommended settings and flow for program and erase operations………. 339

6.6 Memory system programing methods…………………………………………………………………340

6.6.1 Flash memory projects with DRA model…………………………………………………340

6.6.1.1 Flash memory reading projects with DRA model…………………….340

6.6.1.2 Flash memory immediate writing projects with DRA model………343

6.6.1.3 Flash memory burst programing projects with DRA model…….347

6.6.1.4 Flash memory erasing projects with DRA model…………………….. 351

6.6.2 Use API functions in the MSPWare library to perform flash

memory programing……………………………………………………………………………….354

6.6.2.1 Flash reading-related API functions…………………………………………355

6.6.2.2 Flash programing-related API functions…………………………………. 357

6.6.2.3 Flash erasing-related API functions………………………………………….358

6.6.2.4 Flash program-erase protection-related functions……………………358

6.6.2.5 Flash interrupt processing-related API functions……………………..360

6.6.3 Use API functions to build flash memory example projects

with SD model…………………………………………………………………………………………360

6.6.3.1 Configuring the environments and run the project………………….364

6.7 Complete memory map in the MSP432P401R MCU system………………………………….365

6.8 Memory requirements and memory properties…………………………………………………..368

6.8.1 Memory requirements……………………………………………………………………………. 369

6.8.2 Memory access attributes……………………………………………………………………….. 369

6.8.3 Memory endianness……………………………………………………………………………….. 371

6.8.3.1 Little-endian format………………………………………………………………… 371

6.8.3.2 Big-endian format……………………………………………………………………. 372

6.9 Chapter summary………………………………………………………………………………………………. 372

Chapter 7 MSP432™ parallel I/O ports programing………………………………………………….391

7.1 Overview……………………………………………………………………………………………………………. 391

7.2 GPIO module architecture and GPIO port configuration……………………………………. 392

7.3 GPIO ports controlled by using the general digital I/O control…………………………… 394

7.4 GPIO ports controlled by using the PMC…………………………………………………………….402

7.4.1 PM control for GPIO P2…………………………………………………………………………..404

7.4.2 PM control for GPIO P3…………………………………………………………………………..404

7.4.3 PM control for GPIO P7…………………………………………………………………………..406

7.5 On-board keypads interface programing project…………………………………………………408

7.5.1 Keypad interfacing programing structure……………………………………………… 410

7.5.2 Create the keypad interfacing programing project…………………………………. 413

7.5.2.1 Create the C source file DRAKeyPad.c…………………………………….. 413

7.5.3 Set up the environment to build and run the project……………………………… 417

7.6 ADC programing project……………………………………………………………………………………. 417

7.6.1 ADC module in the MSP432P401R MCU system…………………………………….. 418

7.6.2 ADC module architecture and functional block diagram………………………. 418

7.6.2.1 External and internal analog input selection…………………………… 418

7.6.2.2 Internal and external reference voltage selection…………………….. 419

7.6.2.3 ADC clock selection and clock predivision………………………………420

7.6.2.4 ADC triggering source and sample-hold mode selection…………420

7.6.2.5 ADC conversion mode selection……………………………………………….422

7.6.2.6 ADC conversion result memory-register selection…………………… 424

7.6.2.7 ADC power management…………………………………………………………425

7.6.2.8 ADC conversion interrupt-source selection and processing……..425

7.6.3 ADC14 core and conversion result format……………………………………………….427

7.6.4 ADC14 registers………………………………………………………………………………………428

7.6.4.1 ADC14 control register 0 (ADC14CTL0)……………………………………429

7.6.4.2 ADC14 control register 1 (ADC14CTL1)……………………………………429

7.6.4.3 ADC14 conversion memory control registers

(ADC14MCTL0~ ADC14MCTL31)……………………………………………..429

7.6.4.4 ADC14 conversion memory registers

(ADC14MEM0~ADC14MEM31)………………………………………………..429

7.6.4.5 ADC14 interrupt enable registers (ADC14IER0~ADC14IER1)……….433

7.6.4.6 ADC14 interrupt flag registers (ADC14IFGR0~ADC14IFGR1)………435

7.6.4.7 ADC14 clear interrupt flag registers

(ADC14CLRIFGR0~ADC14CLRIFGR1)……………………………………..435

7.6.4.8 ADC14 interrupt vector register (ADC14IV)……………………………..436

7.6.5 Analog input signal channels and GPIO pins…………………………………………. 437

7.6.6 ADC14 module initialization………………………………………………………………….. 437

7.6.7 Build the ADC programing project…………………………………………………………438

7.6.7.1 ADC module in EduBASE ARM® trainer………………………………….438

7.6.7.2 Create the ADC programing project (polling-driven)………………. 439

7.6.7.3 Create the source file DRAADC14.c………………………………………….440

7.6.7.4 Set up the environment to build and run the project………………..442

7.6.8 ADC module API functions provided in the TivaWare peripheral

driver library…………………………………………………………………………………………..442

7.6.8.1 Configure and set up the ADC14 module API functions………….443

7.6.8.2 Enable and disable the ADC14 module API functions……………..447

7.6.8.3 Get the running status and receive the ADC14 conversion

results API functions………………………………………………………………..448

7.6.8.4 Configure and process the ADC14 interrupts API functions………..448

7.6.8.5 Build an example ADC14 project using API functions……………..450

7.7 Analog comparator project………………………………………………………………………………….. 452

7.7.1 Architecture and organization of the COMP_E Module………………………….453

7.7.2 Compared analog inputs selection………………………………………………………….453

7.7.3 Reference voltages selection…………………………………………………………………….455

7.7.4 Comparator output controls……………………………………………………………………. 457

7.7.5 Comparator interrupt controls………………………………………………………………… 459

7.7.6 Analog comparator interfacing signals and GPIO pins…………………………… 462

7.7.7 Initialization and configuration process for the analog comparator………..463

7.7.8 Develop an example analog comparator project………………………………………464

7.7.9 Analog comparator API functions in the MSPPDL………………………………….466

7.7.9.1 API functions used to initialize COMP_E modules…………………. 467

7.7.9.2 API functions used to set up reference voltages………………………. 467

7.7.9.3 API functions used to control and manage the

COMP_E modules……………………………………………………………………. 469

7.7.9.4 API functions used to manage interrupts related

to the COMP_E modules………………………………………………………….. 469

7.7.10 Use API functions to build a comparator project with the SD model……… 470

7.8 Chapter summary………………………………………………………………………………………………. 475

Chapter 8 MSP432™ serial I/O ports programing…………………………………………………….487

8.1 Overview……………………………………………………………………………………………………………. 487

8.2 Introduction to SPI mode and SPI operations………………………………………………………488

8.2.1 Architecture and organization of the SPI mode………………………………………488

8.2.2 CKPL and CKPH (transmit–receive frame)……………………………………………..489

8.3 Enhanced universal serial communication interfaces eUSCI_A and eUSCI_B…………490

8.4 eUSCI interface used for SPI mode……………………………………………………………………… 491

8.4.1 Architecture and functional block diagram of the eUSCI used

for SPI mode…………………………………………………………………………………………… 492

8.4.2 General controls and bit clock generation registers………………………………… 492

8.4.3 SPI data transmit control registers………………………………………………………….. 495

8.4.4 SPI data receiving control registers…………………………………………………………. 496

8.4.5 SPI interrupt-related control registers…………………………………………………….. 497

8.4.5.1 SPI transmit interrupt operation……………………………………………… 497

8.4.5.2 SPI receive interrupt operation………………………………………………… 498

8.4.6 eUSCI_Ax module operational principle………………………………………………… 498

8.4.6.1 Master mode……………………………………………………………………………. 498

8.4.6.2 Slave mode……………………………………………………………………………….499

8.4.6.3 SPI mode enable……………………………………………………………………….500

8.4.6.4 SPI mode working in the low-power modes……………………………..500

8.4.6.5 Initialization and configuration of the eUSCI module………………500

8.4.7 eUSCI for SPI mode control signals and GPIO pins in MSP432P401R EVB…….501

8.4.8 Build the on-board LCD interface programing project……………………………502

8.4.8.1 eUSCI_B0 for SPI mode interface for the LCD in EduBASE

ARMR trainer……………………………………………………………………………502

8.4.8.2 Serial shift register 74VHCT595………………………………………………..502

8.4.8.3 LCD module TC1602A and LCD controller SPLC780………………..503

8.4.8.4 Build the example LCD interfacing project……………………………… 514

8.4.9 Build on-board seven-segment LED interface programing project…………. 520

8.4.9.1 Structure of seven-segment LEDs……………………………………………. 520

8.4.9.2 USCIB0 module interface to the seven-segment LED

in the EduBASE ARMR trainer………………………………………………… 520

8.4.9.3 Build an example LED interfacing project……………………………….. 522

8.4.10 Build DAC programing project………………………………………………………………. 526

8.4.10.1 eUSCI_B0 module interface to the MCP4922

in the EduBASE ARMR trainer………………………………………………… 526

8.4.10.2 Operations and programing for MCP4922 DAC………………………. 526

8.4.10.3 Analog-to-digital converter TLC-548……………………………………….. 528

8.4.10.4 Build the example DAC interfacing project……………………………… 529

8.4.11 eUSCI SPI API functions provided by MSPWare Peripheral

Driver Library…………………………………………………………………………………………534

8.4.11.1 eUSCI_SPI_MasterConfig and eUSCI_SPI_

SlaveConfig structs…………………………………………………………….. 535

8.4.11.2 SPI module initialization and configuration functions……………..535

8.4.11.3 SPI module control and status functions………………………………….535

8.4.11.4 SPI module data processing functions……………………………………..535

8.4.11.5 SPI module interrupt source and processing functions……………. 537

8.4.11.6 Build an example project to interface serial peripherals

using the SPI module……………………………………………………………….538

8.5 Inter-Integrated Circuit (I2C) interface…………………………………………………………………543

8.5.1 I2C module bus configuration and operational status……………………………..543

8.5.2 I2C module architecture and functional block diagram………………………….544

8.5.3 I2C module data transfer format and frame…………………………………………….546

8.5.4 I2C module operational sequence……………………………………………………………546

8.5.4.1 I2C module works in the master transmit mode………………………547

8.5.4.2 I2C module works in the master receive mode…………………………548

8.5.4.3 I2C module works in the slave transmit and receive modes……..549

8.5.5 I2C module major operational control signals………………………………………… 552

8.5.5.1 Acknowledge……………………………………………………………………………553

8.5.5.2 Repeated start…………………………………………………………………………..553

8.5.5.3 Clock low timeout (CLTO)………………………………………………………..553

8.5.5.4 Multiple slave addresses…………………………………………………………..553

8.5.5.5 Arbitration……………………………………………………………………………….553

8.5.5.6 Glitch suppression in multimaster configuration……………………..554

8.5.6 I2C module running speeds (clock rates) and interrupts…………………………554

8.5.6.1 I2C module interrupts generation and processing……………………554

8.5.7 I2C interface control signals and GPIO I2C control registers…………………..556

8.5.8 I2C module control registers and their functions……………………………………. 557

8.5.8.1 eUSCI_B module for I2C mode control registers……………………… 557

8.5.8.2 eUSCI_B module for I2C mode transmit and

receive registers………………………………………………………………….559

8.5.8.3 eUSCI_B module for I2C mode status and error control

registers…………………………………………………………………………………… 559

8.5.8.4 eUSCI_B module for I2C mode addresses control registers……… 561

8.5.8.5 eUSCI_B module for I2C mode interrupt control registers……….563

8.5.9 eUSCI_B module for I2C mode initializations and configurations…………..564

8.5.9.1 Initializations and configurations for the I2C-related

GPIO pins…………………………………………………………………………………565

8.5.9.2 Initializations and configurations for the eUSCI_B1

module for I2C mode………………………………………………………………..565

8.5.10 Build example I2C module projects…………………………………………………………565

8.5.10.1 Hardware configuration for the master and the slave device……….565

8.5.10.2 Master side program………………………………………………………………..565

8.5.10.3 Slave side program…………………………………………………………………..566

8.5.10.4 Create and build the master side program DRAI2CMaster……… 567

8.5.10.5 Create and build the slave side program DRAI2CSlave…………… 570

8.5.10.6 Set up the environment to build and run the project……………….. 571

8.5.11 I2C API functions provided by MSPWare Peripheral Driver Library……… 571

8.5.11.1 Master operations……………………………………………………………………. 573

8.5.11.2 I2C module master initialization and configuration

API functions…………………………………………………………………………… 573

8.5.11.3 I2C module master sending and receiving data API functions…….573

8.5.11.4 Slave operations………………………………………………………………………. 575

8.5.11.5 I2C module slave initialization and configuration API

functions…………………………………………………………………………………. 575

8.5.11.6 I2C module slave sending and receiving data API functions…… 575

8.5.11.7 I2C module interrupt handling and processing

API functions……………………………………………………………………… 577

8.6 Universal asynchronous receivers/transmitters………………………………………………….. 578

8.6.1 MSP432 asynchronous serial communication protocols

and data framing…………………………………………………………………………………….580

8.6.2 Architecture and organization of the eUSCI_A module for UART mode………581

8.6.3 Control registers used in eUSCI_A module for UART mode…………………..583

8.6.3.1 UART control and status registers……………………………………………583

8.6.3.2 UART baud rate generation and control registers……………………. 587

8.6.3.3 UART data transmit and receive registers………………………………..588

8.6.3.4 UART interrupt processing registers………………………………………..588

8.6.4 Operational procedure of the UART and some important properties…….. 589

8.6.4.1 UART initialization and configuration…………………………………….. 589

8.6.4.2 UART baud rate generation………………………………………………………590

8.6.4.3 UART transmit enable and data transmit operation………………… 590

8.6.4.4 UART receive enable and data receive operation……………………… 591

8.6.4.5 UART errors detection…………………………………………………………….. 592

8.6.5 UART modem handshake serial communication mode………………………….. 593

8.6.6 eUSCI_A module for UART control signals and GPIO pins……………………. 594

8.6.7 Develop an example eUSCI_A2 UART mode project……………………………… 594

8.6.7.1 Initialize and configure the UART-related GPIO ports

and pins…………………………………………………………………………………. 595

8.6.7.2 Initialize and configure clock source and baud rate

for the UART module………………………………………………………………. 595

8.6.7.3 Initialize and configure the eUSCI_A2 for UART mode………….. 595

8.6.7.4 Build an example UART module project………………………………….. 596

8.6.7.5 A practical example URAT lab project with two UART modes……. 599

8.6.8 UART API functions provided by the MSPWare Peripheral

Driver Library…………………………………………………………………………………………600

8.6.8.1 UART initialization and configuration API functions……………… 601

8.6.8.2 UART control and status API functions…………………………………… 601

8.6.8.3 UART send and receive data API functions…………………………….. 601

8.6.8.4 UART interrupt handling API functions…………………………………. 601

8.7 Chapter summary……………………………………………………………………………………………….604

Chapter 9 MSP432™ 16-bit timers and PWM modules……………………………………………..637

9.1 Overview……………………………………………………………………………………………………………. 637

9.2 Timer_A architecture and functional block diagram…………………………………………..638

9.3 Timer_A modules operations……………………………………………………………………………… 639

9.3.1 Timer_A module control………………………………………………………………………… 639

9.3.2 Timer_A module operation modes…………………………………………………………. 641

9.3.2.1 Continuous mode……………………………………………………………………. 641

9.3.2.2 Up-count mode……………………………………………………………………….. 641

9.3.2.3 Up/down-count mode………………………………………………………………642

9.3.2.4 Capture/compare control block………………………………………………..643

9.3.3 Output examples of using three operational modes………………………………..646

9.3.3.1 Output implementations for Timer_A module

in the up-count mode……………………………………………………………….647

9.3.3.2 Output implementations for Timer_A module

in the continuous mode……………………………………………………………647

9.3.3.3 Output implementations for Timer_A module

in the up–down-count mode…………………………………………………….647

9.3.3.4 Timer_A interrupt processing………………………………………………….648

9.3.4 Implementations of the Timer_A modules………………………………………………650

9.3.4.1 Input edge-count mode……………………………………………………………. 651

9.3.4.2 Input edge-time mode……………………………………………………………… 652

9.3.4.3 PWM mode………………………………………………………………………………653

9.3.5 Timer_A module GPIO-related control signals………………………………………..653

9.3.6 Build example Timer_A module projects………………………………………………..656

9.3.7 Popular implementations on Timer_A modules………………………………………659

9.3.7.1 Input edge-count implementations…………………………………………..659

9.3.7.2 Input edge-time implementations…………………………………………….659

9.3.7.3 PWM implementations…………………………………………………………….663

9.3.8 API functions used for Timer_A module………………………………………………… 671

9.3.8.1 Timer_A module-related structs……………………………………………… 672

9.3.8.2 API functions for Timer_A module (TA0~TA3) CFGCTRL……….. 673

9.3.8.3 Timer_A module five capture/compare CFGCTRL API

functions…………………………………………………………………………………. 675

9.3.8.4 API functions used for Clock System Configuration

and Control……………………………………………………………………………… 676

9.3.8.5 Implementation of using Timer_A API functions

to measure PWM pulses………………………………………………………….. 679

9.4 Chapter summary……………………………………………………………………………………………….686

Chapter 10 MSP432 32-bit timers and watchdog timer………………………………………………703

10.1 Overview……………………………………………………………………………………………………………. 703

10.2 MSP432 Timer32 modules…………………………………………………………………………………… 704

10.2.1 Architecture and function block diagram of the Timer32 module………….. 704

10.2.2 Operations of the Timer32 modules……………………………………………………….. 705

10.2.3 Mappings among the Timer32 registers and programing macros…………… 706

10.2.4 An example Timer32 module application project……………………………………. 708

10.2.5 API functions used for Timer32 timers in the MSPWare driver library……. 710

10.2.5.1 API functions used to initialize and configure Timer32 module……710

10.2.5.2 API functions used to check the working status

of the Timer32 module…………………………………………………………….. 710

10.2.5.3 API functions used to configure and handle interrupts

of the Timer32 module…………………………………………………………….. 712

10.3 MSP432 watchdog timer……………………………………………………………………………………… 712

10.3.1 Two operational modes of the watchdog timer……………………………………….. 713

10.3.1.1 Watchdog timer mode……………………………………………………………… 713

10.3.1.2 Interval timer mode…………………………………………………………………. 713

10.3.2 Architecture and functional block diagram of the WDT_A module……….. 713

10.3.3 Watchdog timer-related interrupts and flags………………………………………….. 714

10.3.4 Watchdog timer operation in different power modes……………………………… 716

10.3.5 Mappings among the WDT_A bit values and programing macros…………. 716

10.3.6 Build an example watchdog timer project………………………………………………. 717

10.3.7 API functions used for WDT_A timer in the mspware driver library…….. 718

10.3.7.1 API functions used to initialize and configure

the WDT_A module…………………………………………………………………. 718

10.3.7.2 API functions used to operate the WDT_A module…………………. 719

10.3.7.3 API functions used to configure and handle interrupts

of the WDT_A module…………………………………………………………….. 720

10.3.7.4 System control-related API functions used to set up

the reset types…………………………………………………………………………. 720

10.3.7.5 Build an example WDT_A project with API functions…………….. 721

10.4 Chapter summary……………………………………………………………………………………………….723

Chapter 11 MSP432™ floating-point unit (FPU)………………………………………………………….735

11.1 Overview…………………………………………………………………………………………………………….735

11.2 Three types of the floating-point data………………………………………………………………….736

11.2.1 Half-precision floating-point data……………………………………………………………736

11.2.2 Single-precision floating-point data…………………………………………………………738

11.2.3 Double-precision floating-point data………………………………………………………. 740

11.3 FPU in the Cortex®-M4 MCU………………………………………………………………………………. 742

11.3.1 Architecture of the floating-point registers…………………………………………….. 743

11.3.2 FPU operational modes………………………………………………………………………….. 745

11.4 Implementing the FPU………………………………………………………………………………………… 746

11.4.1 Floating-point support in CMSIS-Core…………………………………………………… 746

11.4.2 Floating-point programing in the MSP432P401R MCU system……………….. 746

11.4.2.1 FPU in the DRA model……………………………………………………………. 747

11.4.2.2 FPU in the SD model………………………………………………………………..750

11.4.3 A FPU example project using the DRA model…………………………………………750

11.5 Chapter summary……………………………………………………………………………………………….754

Chapter 12 MSP432™ memory protection unit (MPU)………………………………………………. 761

12.1 Overview……………………………………………………………………………………………………………. 761

12.2 Implementation of the MPU……………………………………………………………………………….. 762

12.2.1 Memory regions, types, and attributes…………………………………………………… 763

12.2.2 MPU Configuration and Control Registers…………………………………………….. 763

12.2.2.1 MPU type register (MPUTYPE)………………………………………………. 764

12.2.2.2 MPU control register (MPUCTRL)…………………………………………… 764

12.2.2.3 MPU region number register (MPUNUMBER)……………………….. 765

12.2.2.4 MPU region base address register (MPUBASE)……………………….. 765

12.2.2.5 MPU region attribute and size register (MPUATTR)……………….. 766

12.3 Initialization and configuration of the MPU……………………………………………………….. 769

12.4 Building a practical example MPU project………………………………………………………….. 769

12.4.1 Create a new DRA model MPU project DRAMPU…………………………………. 770

12.4.2 Set up the environment to build and run the project……………………………… 774

12.5 API functions provided by the MSPWare Peripheral Driver Library……………………775

12.5.1 MPU setup and status API functions……………………………………………………… 776

12.5.1.1 API function MPU_setRegion()……………………………………………….. 776

12.5.2 MPU module enable and disable API functions………………………………………778

12.5.3 MPU interrupt handler control API functions…………………………………………779

12.6 Chapter summary……………………………………………………………………………………………….779

Appendix A: Download and install Keil MDK-ARM 5.15 IDE and MSP432 DFP………….. 787

Appendix B: Download and install MSPWare software package…………………………………. 793

Appendix C: MSP432P401R-based EVB hardware setup………………………………………………. 797

Appendix D: The CMSIS core-specific intrinsic functions…………………………………………….799

Index……………………………………………………………………………………………………………………………. 801

About the Author

Author

Dr. Ying Bai is a professor in the Department of Computer Science and Engineering at Johnson C. Smith University in Charlotte, North Carolina. His special research interests include intelligent controls, soft computing, mixed-language programming, fuzzy logic controls, robotic controls, robots calibrations, and fuzzy multicriteria decision-making. He has had industry experience in software and senior software engineer positions at companies such as Motorola MMS, Schlumberger ATE Technology, Immix Telecom, and Lam Research.

Dr. Bai has published approximately 50 academic research papers in IEEE Trans. Journals and international conferences. He has also published 13 books with publishers such as Prentice Hall, CRC Press LLC, Springer, Cambridge University Press, and Wiley IEEE Press in recent years. The Russian translation of his first book titled Applications Interface Programming Using Multiple Languages was published by Prentice Hall in 2005. The Chinese translation of his eighth book titled Practical Database Programming with Visual C#.NET was published by Tsinghua University Press in China at the end of 2011. His books cover interfacing software programming, serial port programming, database programming, and fuzzy logic controls in industrial applications, as well as microcontroller programming and applications.

Subject Categories

BISAC Subject Codes/Headings:
SCI024000
SCIENCE / Energy
TEC007000
TECHNOLOGY & ENGINEERING / Electrical
TEC008000
TECHNOLOGY & ENGINEERING / Electronics / General