The Firmware Handbook provides a comprehensive reference for firmware developers looking to increase their skills and productivity. It addresses each critical step of the development process in detail, including how to optimize hardware design for better firmware. Topics covered include real-time issues, interrupts and ISRs, memory management (including Flash memory), handling both digital and analog peripherals, communications interfacing, math subroutines, error handling, design tools, and troubleshooting and debugging.
This book is not for the beginner, but rather is an in-depth, comprehensive one-volume reference that addresses all the major issues in firmware design and development, including the pertinent hardware issues.
Inhaltsverzeichnis
1;Cover;1 2;TOC$Contents;8 3;Acknowledgements;6 4;Contents;8 5;Preface;16 6;I. Basic Hardware;18 6.1;I. Introduction;20 6.2;CH$1. Basic Electronics;22 6.2.1;DC Circuits;22 6.2.2;AC Circuits;31 6.2.3;Active Devices;37 6.2.4;Putting it Togethera Power Supply;41 6.2.5;The Scope;44 6.3;CH$2. Logic Circuits;50 6.3.1;Coding;50 6.3.2;Combinatorial Logic;53 6.3.3;Sequential Logic;60 6.3.4;Logic Wrap-up;64 6.4;CH$3. Hardware Design Tips;66 6.4.1;Diagnostics;66 6.4.2;Connecting Tools;67 6.4.3;Other Thoughts;68 6.4.4;Summary;69 7;II. Designs;70 7.1;II. Introduction;72 7.2;CH$4. Tools and Methods for Improving Code Quality;74 7.2.1;Introduction;74 7.2.2;The Traditional Serial Development Cycle of an Embedded Design;74 7.2.3;Typical Challenges in Todays Embedded Market;75 7.2.4;Generic Methods to Improve Code Quality and Reduce the Time-to-Market;76 7.2.5;Major Time Factors for the Engineering Cycle;77 7.2.6;Where is Most Time Needed?;77 7.2.7;How to Improve Software Development Time and Code Quality;77 7.2.8;How to Reduce Hardware Development Time;81 7.2.9;Outlook and Summary;82 7.3;CH$5. Tips to Improve Functions;86 7.3.1;Minimize Functionality;86 7.3.2;Encapsulate;87 7.3.3;Remove Redundancies;87 7.3.4;Reduce Real-Time Code;88 7.3.5;Flow With Grace;88 7.3.6;Refactor Relentlessly;89 7.3.7;Employ Standards and Inspections;89 7.3.8;Comment Carefully;90 7.3.9;Summary;92 7.4;CH$6. Evolutionary Development;94 7.4.1;Introduction;94 7.4.2;1. History;95 7.4.3;2. Issues Addressed by Evo;97 7.4.4;3. How Do We Use Evo in Projects;106 7.4.5;4. Check Lists;109 7.4.6;5. Introducing Evo in New Projects;111 7.4.7;6. Testing With Evo;112 7.4.8;7. Change Requests and Problem Reports;113 7.4.9;8. Tools;114 7.4.10;9. Conclusion;115 7.4.11;Acknowledgment;116 7.4.12;References;116 7.5;CH$7. Embedded State Machine Implementation;118 7.5.1;State Machines;118 7.5.2;An Example;119 7.5.3;Implementation;121 7.5.4;Testing;125 7.5.5;Crank It;125 7.5.6;References;126 7.6;CH$8. Hierarchical State Machines;128
7.6.1;Conventional State Machine Example;129 7.6.2;Hierarchical State Machine Example;131 7.7;CH$9. Developing Safety Critical Applications;138 7.7.1;Introduction;138 7.7.2;Reliability and safety;138 7.7.3;Along came DO-178B;139 7.7.4;Overview of DO-178B;140 7.7.5;Failure Condition Categorization;140 7.7.6;System Architectural Considerations;142 7.7.7;System Architectural Documentation;143 7.7.8;DO-178B Software life cycle;143 7.7.9;Object Oriented Technology and Safety Critical Software Challenges;148 7.7.10;Iterative Process;149 7.7.11;Issues Facing OO Certification;150 7.7.12;Summary;153 7.7.13;References;153 7.8;CH$10. Installing and Using a Version Control System;154 7.8.1;Introduction;154 7.8.2;The Power and Elegance of Simplicity;155 7.8.3;Version Control;155 7.8.4;Typical Symptoms of Not (Fully) Utilizing a Version Control System;156 7.8.5;Simple Version Control Systems;156 7.8.6;Advanced Version Control Systems;156 7.8.7;What Files to Put Under Version Control;157 7.8.8;Sharing of Files and the Version Control Client;157 7.8.9;Integrated Development Environment Issues;158 7.8.10;Graphical User Interface (GUI) Issues;158 7.8.11;Common Source Code Control Specification;159 7.8.12;World Wide Web Browser Interface or Java Version Control Client;159 7.8.13;Bug Tracking;166 7.8.14;Non-Configuration Management Tools;167 7.8.15;Closing Comments;168 7.8.16;Suggested Reading, References, and Resources;169 8;III. Math;172 8.1;III. Introduction;174 8.2;CH$11. An Introduction To Machine Calculations;176 8.2.1;Introduction;176 8.2.2;Integer Arithmetic;176 8.2.3;Floating-Point Math;182 8.2.4;Fixed-Point Arithmetic;193 8.2.5;Conclusion;196 8.2.6;Bibliography;196 8.3;CH$12. Floating Point Approximations;198 8.3.1;General Trig Notes;199 8.3.2;Cosine and Sine;199 8.3.3;Higher Precision Cosines;206 8.3.4;Tangent;207 8.3.5;Higher Precision Tangents;212 8.3.6;Arctangent, Arcsine and Arccosine;213 8.4;CH$13. Math Functions;218 8.4.1;Gray Code;218 8.4.2;Integer Multiplication by
a Constant;218 8.4.3;Computing an Exclusive Or;218 8.4.4;Integer Square Roots;219 8.4.5;Important Basic Math Operations;219 8.5;CH$14. IEEE 754 Floating Point Numbers;220 8.5.1;Special values;221 9;IV. Real-Time;224 9.1;IV. Introduction;226 9.2;CH$15. Real-Time Kernels;228 9.2.1;Introduction;228 9.2.2;What is a Real-Time Kernel?;228 9.2.3;What is a task?;229 9.2.4;The Clock Tick;232 9.2.5;Scheduling;233 9.2.6;Context Switching;235 9.2.7;Kernel Services;236 9.2.8;Kernel Services, Semaphores;236 9.2.9;Kernel Services, Message Queues;240 9.2.10;Kernel Services, Memory Management;242 9.2.11;Do You Need a Kernel?;242 9.2.12;Can You Use a Kernel?;243 9.2.13;Selecting a Kernel?;244 9.2.14;Conclusion;246 9.3;CH$16. Reentrancy;248 9.3.1;Atomic Variables;248 9.3.2;Two More Rules;250 9.3.3;Keeping Code Reentrant;251 9.3.4;Recursion;252 9.3.5;Asynchronous Hardware/Firmware;253 9.3.6;Race Conditions;254 9.3.7;Options;255 9.3.8;Other RTOSes;256 9.3.9;Metastable States;257 9.3.10;Firmware, not Hardware;259 9.4;CH$17. Interrupt Latency;262 9.4.1;Taking Data;265 9.5;CH$18. Understanding Your C Compiler: How to Minimize Code Size;268 9.5.1;Modern C Compilers;269 9.5.2;Tips on Programming;276 9.5.3;Final Notes;282 9.5.4;Acknowledgements;283 9.6;CH$19. Optimizing C and C++ Code;284 9.6.1;Adjust Structure Sizes to Power of Two;284 9.6.2;Place Case Labels in Narrow Range;284 9.6.3;Place Frequent Case Labels First;284 9.6.4;Break Big Switch Statements into Nested Switches;285 9.6.5;Minimize Local Variables;286 9.6.6;Declare Local Variables in the Innermost Scope;286 9.6.7;Reduce the Number of Parameters;286 9.6.8;Use References for Parameter Passing and Return Value for Types Bigger than 4 Bytes;286 9.6.9;Dont Define a Return Value if Not Used;287 9.6.10;Consider Locality of Reference for Code and Data;287 9.6.11;Prefer int over char and short;287 9.6.12;Define Lightweight Constructors;288 9.6.13;Prefer Initialization Over Assignment;289 9.6.14;Use Constructor Initialization Lists;289 9.6
.15;Do Not Declare Just in Case Virtual Functions;290 9.6.16;Inline 1 to 3 Line Functions;290 9.7;CH$20. Real-Time Asserts;292 9.7.1;Embedded Issues;292 9.7.2;Real-Time Asserts;293 10;V. Errors and Changes;298 10.1;V. Introduction;300 10.2;CH$21. Implementing Downloadable Firmware With Flash Memory;302 10.2.1;Introduction;302 10.2.2;The Microprogrammer;303 10.2.3;Advantages of Microprogrammers;303 10.2.4;Disadvantages of Microprogrammers;304 10.2.5;Receiving a Microprogrammer;304 10.2.6;A Basic Microprogrammer;305 10.2.7;Common Problems and Their Solutions;306 10.2.8;Hardware Alternatives;312 10.2.9;Separating Code and Data;312 10.3;CH$22. Memory Diagnostics;316 10.3.1;ROM Tests;316 10.3.2;RAM Tests;318 10.4;CH$23. Nonvolatile Memory;324 10.4.1;Supervisory Circuits;324 10.4.2;Multi-byte Writes;326 10.4.3;Testing;328 10.4.4;Conclusion;329 10.5;CH$24. Proactive Debugging;330 10.5.1;Stacks and Heaps;330 10.5.2;Seeding Memory;332 10.5.3;Wandering Code;333 10.5.4;Special Decoders;335 10.5.5;MMUs;335 10.5.6;Conclusion;336 10.6;CH$25. Exception Handling in C++;338 10.6.1;The Mountains (Landmarks of Exception Safety);339 10.6.2;A History of this Territory;340 10.6.3;The Tar Pit;341 10.6.4;Tar!;343 10.6.5;The Royal Road;343 10.6.6;The Assignment OperatorA Special Case;345 10.6.7;In Bad Weather;346 10.6.8;Looking back;349 10.6.9;References;354 10.7;CH$26. Building a Great Watchdog;356 10.7.1;Internal WDTs;359 10.7.2;External WDTs;360 10.7.3;Characteristics of Great WDTs;362 10.7.4;Using an Internal WDT;364 10.7.5;An External WDT;366 10.7.6;WDTs for Multitasking;367 10.7.7;Summary and Other Thoughts;369 11;Appendix A: ASCII Table;372 12;Appendix B: Byte Alignment and Ordering;374 12.1;Byte Alignment Restrictions;374 12.2;Byte Ordering;376 13;IDX$Index;378