ebook img

Getting Started with Tiva ARM Cortex M4 Microcontrollers: A Lab Manual for Tiva LaunchPad Evaluation Kit PDF

282 Pages·2018·13.22 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Getting Started with Tiva ARM Cortex M4 Microcontrollers: A Lab Manual for Tiva LaunchPad Evaluation Kit

Dhananjay V. Gadre Sarthak Gupta Getting Started with Tiva ARM Cortex M4 Microcontrollers A Lab Manual for Tiva LaunchPad Evaluation Kit Getting Started with Tiva ARM Cortex M4 Microcontrollers Dhananjay V. Gadre Sarthak Gupta (cid:129) Getting Started with Tiva ARM Cortex M4 Microcontrollers A Lab Manual for Tiva LaunchPad Evaluation Kit 123 Dhananjay V.Gadre SarthakGupta DivisionofElectronicsandCommunications TICentre for EmbeddedProduct Design Engineering Netaji Subhas Institute of Technology Netaji Subhas Institute of Technology NewDelhi NewDelhi India India ISBN978-81-322-3764-8 ISBN978-81-322-3766-2 (eBook) https://doi.org/10.1007/978-81-322-3766-2 LibraryofCongressControlNumber:2017948637 ©Springer(India)Pvt.Ltd.2018 Thisworkissubjecttocopyright.AllrightsarereservedbythePublisher,whetherthewholeorpart of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission orinformationstorageandretrieval,electronicadaptation,computersoftware,orbysimilarordissimilar methodologynowknownorhereafterdeveloped. The use of general descriptive names, registered names, trademarks, service marks, etc. in this publicationdoesnotimply,evenintheabsenceofaspecificstatement,thatsuchnamesareexemptfrom therelevantprotectivelawsandregulationsandthereforefreeforgeneraluse. The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authorsortheeditorsgiveawarranty,expressorimplied,withrespecttothematerialcontainedhereinor for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictionalclaimsinpublishedmapsandinstitutionalaffiliations. Printedonacid-freepaper ThisSpringerimprintispublishedbySpringerNature TheregisteredcompanyisSpringer(India)Pvt.Ltd. Theregisteredcompanyaddressis:7thFloor,VijayaBuilding,17BarakhambaRoad,NewDelhi110001,India To Professor T. J. Joseph (Newman College, Thodupuza, Kerala). In solidarity. –Dhananjay V. Gadre To my grandparents, parents and my sisters who inspired me to work hard and give my best –Sarthak Gupta Acknowledgements The need for this lab manual arose because Texas Instruments (TI) launched the new TIVA family of Cortex-M microcontroller platform after they obsoleted the Stellaris ARM microcontroller platform in 2012. With the launch of TIVA plat- form, corresponding LaunchPad evaluation kits were also made available. The LaunchPad evaluation kit is very versatile for hardware debugging; however, it lacks suitable sensors for physical interfacing that are critically required for a lab course. This led to the development of the Padma board as described in this text. The following people extended great help in the development of the Padma Board and in completing this book: Dr. C. P. Ravikumar, the then director of university relations at Texas Instruments India; Sagar Juneja also at the Texas Instruments India office at the time together with Vaibhav Ostwal, were very effi- cient in catering to our needs whether they be of chip samples or evaluation kits. SincetakingoverthereinsoftheuniversityrelationsprogramatTexasInstruments, India,SanjaySrivastavaandhisteamhavebeenveryhelpfulandresponsivetoour requirements.ThanksareduetoseveralofmystudentsattheCentreforElectronic DesignandTechnology(CEDT)atNSITwhohelpedinvariousformsthroughthe development of this manuscript and before that during the design of the Padma Board, most notably Rohit Dureja and Anshuman Mishra. I am proud of Sarthak Gupta who has done an admirable job as my co-author! I thank Swati Meherishi, my editor at Springer for her continued support and persistence. She is a big reason for this book to see the light of the day! And most of all, my wife Sangeeta and son Chaitanya for their love, care, and understanding without which I could not have started this project. Dhananjay V. Gadre New Delhi, India vii Contents 1 Introduction... .... .... ..... .... .... .... .... .... ..... .... 1 1 Tiva LaunchPad .... ..... .... .... .... .... .... ..... .... 2 2 PadmaBoard... .... ..... .... .... .... .... .... ..... .... 3 3 Tiva C Series Microcontroller Breakout Board.. .... ..... .... 4 4 Look Ahead!... .... ..... .... .... .... .... .... ..... .... 5 5 List of Experiments . ..... .... .... .... .... .... ..... .... 6 2 ARM Cortex-M4 Core and Tiva C Series Peripherals.. ..... .... 13 1 Overview of ARM Cortex-M4 Architecture.... .... ..... .... 14 2 Cortex-M4 Core Peripherals.... .... .... .... .... ..... .... 15 2.1 Nested Vectored Interrupt Controller (NVIC) . ..... .... 15 2.2 Floating Point Unit (FPU).... .... .... .... ..... .... 16 2.3 System Control Block (SCB) . .... .... .... ..... .... 16 2.4 System Timer-SysTick .. .... .... .... .... ..... .... 16 2.5 Memory Protection Unit (MPU) ... .... .... ..... .... 16 3 Programmer’s Model ..... .... .... .... .... .... ..... .... 17 3.1 Processor Modes... .... .... .... .... .... ..... .... 17 3.2 Privilege Levels.... .... .... .... .... .... ..... .... 17 3.3 Stacks.. .... ..... .... .... .... .... .... ..... .... 18 3.4 Core Registers..... .... .... .... .... .... ..... .... 18 4 Memory Model. .... ..... .... .... .... .... .... ..... .... 20 4.1 Memory Map ..... .... .... .... .... .... ..... .... 20 4.2 Bit Banding.. ..... .... .... .... .... .... ..... .... 20 4.3 Memory Endianness .... .... .... .... .... ..... .... 22 5 Advanced Microcontroller Bus Architecture (AMBA) ..... .... 23 5.1 Advanced High-Performance Bus (AHB) .... ..... .... 24 5.2 Advanced Peripheral Bus (APB)... .... .... ..... .... 24 6 Texas Instruments Tiva C Series Family .. .... .... ..... .... 24 ix x Contents 3 Tiva C Series LaunchPad..... .... .... .... .... .... ..... .... 27 1 Board Overview.... ..... .... .... .... .... .... ..... .... 27 2 Hardware Description..... .... .... .... .... .... ..... .... 28 2.1 Power Supply ..... .... .... .... .... .... ..... .... 28 2.2 Hibernate.... ..... .... .... .... .... .... ..... .... 28 2.3 Clock .. .... ..... .... .... .... .... .... ..... .... 29 2.4 Reset... .... ..... .... .... .... .... .... ..... .... 29 2.5 In-Circuit Debug Interface (ICDI).. .... .... ..... .... 30 2.6 LEDs and Switches. .... .... .... .... .... ..... .... 30 2.7 Microcontroller Expansion Headers. .... .... ..... .... 31 4 PadmaBoard—Peripheral Motherboard of Tiva C Series LaunchPad.... .... .... ..... .... .... .... .... .... ..... .... 33 1 Board Overview.... ..... .... .... .... .... .... ..... .... 33 2 Schematic and Layout .... .... .... .... .... .... ..... .... 35 3 Pin Assignment to Peripherals .. .... .... .... .... ..... .... 37 4 Peripherals Description.... .... .... .... .... .... ..... .... 37 4.1 Temperature Sensor. .... .... .... .... .... ..... .... 37 4.2 Audio Input.. ..... .... .... .... .... .... ..... .... 37 4.3 Light Sensor . ..... .... .... .... .... .... ..... .... 40 4.4 I2C Bus Connector and Magnetic Field Sensor..... .... 40 4.5 IR Transmitter and Receiver; and Ultrasonic Sensor Connector ... ..... .... .... .... .... .... ..... .... 41 4.6 Buzzer.. .... ..... .... .... .... .... .... ..... .... 42 4.7 Three LEDs.. ..... .... .... .... .... .... ..... .... 42 4.8 Serial Communication Port Using UART Protocol.. .... 43 4.9 Serial LCD with 16 Keys Keypad.. .... .... ..... .... 44 4.10 PS/2 Connector.... .... .... .... .... .... ..... .... 46 4.11 MicroSD Card Interface . .... .... .... .... ..... .... 46 4.12 TV and Potentiometer... .... .... .... .... ..... .... 46 4.13 Real-Time Clock (RTC) . .... .... .... .... ..... .... 47 4.14 Dual DAC with Audio Out... .... .... .... ..... .... 48 5 Jumper Selection.... ..... .... .... .... .... .... ..... .... 48 5 Tiva C Series Microcontroller Breakout Board ... .... ..... .... 53 1 Board Overview.... ..... .... .... .... .... .... ..... .... 53 2 Schematic and Layout .... .... .... .... .... .... ..... .... 55 3 Hardware Description..... .... .... .... .... .... ..... .... 55 3.1 Power Supply ..... .... .... .... .... .... ..... .... 55 3.2 Hibernate.... ..... .... .... .... .... .... ..... .... 56 3.3 Clock .. .... ..... .... .... .... .... .... ..... .... 57 3.4 Reset... .... ..... .... .... .... .... .... ..... .... 58 3.5 Debug Connector .. .... .... .... .... .... ..... .... 58 3.6 LED and Switches . .... .... .... .... .... ..... .... 59 3.7 Microcontroller Expansion Headers. .... .... ..... .... 59 4 Programming Tiva C Series Microcontrollers... .... ..... .... 59 Contents xi 6 GNU ARM Toolchain .. ..... .... .... .... .... .... ..... .... 61 1 Introduction ... .... ..... .... .... .... .... .... ..... .... 61 2 Programming Environment Components... .... .... ..... .... 62 2.1 Preprocessing ..... .... .... .... .... .... ..... .... 63 2.2 Compiling... ..... .... .... .... .... .... ..... .... 64 2.3 Assembling.. ..... .... .... .... .... .... ..... .... 64 2.4 Linking. .... ..... .... .... .... .... .... ..... .... 64 3 Programming Environment for Tiva C Series Microcontroller Family ... .... .... ..... .... .... .... .... .... ..... .... 64 4 Setting up the Development Environment.. .... .... ..... .... 66 7 Structure of Embedded C Program .... .... .... .... ..... .... 85 1 Anatomy of Embedded C Program... .... .... .... ..... .... 85 2 Experiment 1—Blinky .... .... .... .... .... .... ..... .... 87 2.1 Objective.... ..... .... .... .... .... .... ..... .... 87 2.2 Hardware Description ... .... .... .... .... ..... .... 87 2.3 Program Flow..... .... .... .... .... .... ..... .... 88 2.4 Register Accesses .. .... .... .... .... .... ..... .... 89 2.5 Program Code..... .... .... .... .... .... ..... .... 89 3 Experiment 2—Switchy ... .... .... .... .... .... ..... .... 90 3.1 Objective.... ..... .... .... .... .... .... ..... .... 90 3.2 Hardware Description ... .... .... .... .... ..... .... 90 3.3 Program Flow..... .... .... .... .... .... ..... .... 91 3.4 Register Accesses .. .... .... .... .... .... ..... .... 91 3.5 Program Code..... .... .... .... .... .... ..... .... 92 8 Application Programming Interface (API) ... .... .... ..... .... 95 1 Peripheral Driver Library .. .... .... .... .... .... ..... .... 95 2 Programming Models..... .... .... .... .... .... ..... .... 96 2.1 Direct Register Access Model. .... .... .... ..... .... 96 2.2 Software Driver Model.. .... .... .... .... ..... .... 97 2.3 Using Both Models. .... .... .... .... .... ..... .... 97 3 Useful API Function Calls . .... .... .... .... .... ..... .... 97 9 Digital Input/Output.... ..... .... .... .... .... .... ..... .... 101 1 Experiment 3—API Blinky. .... .... .... .... .... ..... .... 101 1.1 Objective.... ..... .... .... .... .... .... ..... .... 101 1.2 Hardware Description ... .... .... .... .... ..... .... 101 1.3 Program Flow..... .... .... .... .... .... ..... .... 102 1.4 Useful API Function Calls ... .... .... .... ..... .... 102 1.5 Program Code..... .... .... .... .... .... ..... .... 105 2 Experiment 4—API Switchy.... .... .... .... .... ..... .... 106 2.1 Objective.... ..... .... .... .... .... .... ..... .... 106 2.2 Hardware Description ... .... .... .... .... ..... .... 106 xii Contents 2.3 Program Flow..... .... .... .... .... .... ..... .... 106 2.4 Useful API Functions Calls... .... .... .... ..... .... 107 2.5 Program Code..... .... .... .... .... .... ..... .... 109 3 Experiment 5—Running LEDs.. .... .... .... .... ..... .... 110 3.1 Objective.... ..... .... .... .... .... .... ..... .... 110 3.2 Hardware Description ... .... .... .... .... ..... .... 111 3.3 Program Flow..... .... .... .... .... .... ..... .... 111 4 Experiment 6—LED as Light Sensor. .... .... .... ..... .... 112 4.1 Objective.... ..... .... .... .... .... .... ..... .... 112 4.2 Hardware Description ... .... .... .... .... ..... .... 112 4.3 Program Flow..... .... .... .... .... .... ..... .... 115 5 Experiment 7—Switch Toggle .. .... .... .... .... ..... .... 115 5.1 Objective.... ..... .... .... .... .... .... ..... .... 115 5.2 Hardware Description ... .... .... .... .... ..... .... 117 5.3 Experiment Tips ... .... .... .... .... .... ..... .... 117 6 Experiment 8—Electronic Dice . .... .... .... .... ..... .... 117 6.1 Objective.... ..... .... .... .... .... .... ..... .... 117 6.2 Hardware Description ... .... .... .... .... ..... .... 117 6.3 Experiment Tips ... .... .... .... .... .... ..... .... 117 7 Experiment 9—Live Morse Generation ... .... .... ..... .... 118 7.1 Objective.... ..... .... .... .... .... .... ..... .... 118 7.2 Hardware Description ... .... .... .... .... ..... .... 118 7.3 Experiment Tips ... .... .... .... .... .... ..... .... 119 8 Experiment 10—Morse Recorder .... .... .... .... ..... .... 120 8.1 Objective.... ..... .... .... .... .... .... ..... .... 120 8.2 Hardware Description ... .... .... .... .... ..... .... 120 9 Experiment 11—Car Parking Sensor . .... .... .... ..... .... 120 9.1 Objective.... ..... .... .... .... .... .... ..... .... 120 9.2 Hardware Description ... .... .... .... .... ..... .... 120 9.3 Experiment Tips ... .... .... .... .... .... ..... .... 122 10 Interrupts. .... .... .... ..... .... .... .... .... .... ..... .... 123 1 Exception Handling . ..... .... .... .... .... .... ..... .... 123 1.1 Exception States ... .... .... .... .... .... ..... .... 124 1.2 Exception Types... .... .... .... .... .... ..... .... 124 1.3 Exception Handler.. .... .... .... .... .... ..... .... 126 1.4 Exception Priorities. .... .... .... .... .... ..... .... 126 2 Experiment 12—Interrupt Switchy... .... .... .... ..... .... 126 2.1 Objective.... ..... .... .... .... .... .... ..... .... 126 2.2 Hardware Description ... .... .... .... .... ..... .... 127 2.3 Program Flow..... .... .... .... .... .... ..... .... 127 2.4 Useful API Function Calls ... .... .... .... ..... .... 128

Description:
The book presents laboratory experiments concerning ARM microcontrollers, and discusses the architecture of the Tiva Cortex-M4 ARM microcontrollers from Texas Instruments, describing various ways of programming them. Given the meager peripherals and sensors available on the kit, the authors describe
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.