Share E-Book
Scan to open this page

Scan with your phone to open this page

Author(美)怀特(White, E.)

《O'Reilly精品图书系列:嵌入式系统设计与实践》深入分析嵌入式系统的架构设计步骤和架构设计模式。介绍嵌入式系统中独有的设计模式,如环形缓冲区、中断和定时器、硬件调试、PID控制、系统优化等。《O'Reilly精品图书系列:嵌入式系统设计与实践》探讨了扫描仪、电机以及其他I/O设备。介绍事半功倍的方案:降低内存消耗、代码空间占用、处理器周期以及功耗。·学习如何在处理器中直接更新嵌入式程序代码。 O'Reilly Media通过图书、杂志、在线服务、调查研究和会议等方式传播创新知识。自1978年开始,O’Reilly一直都是前沿发展的见证者和推动者。超级极客们正在开创着未来,而我们关注真正重要的技术趋势——通过放大那些“细微的信号”来刺激社会对新科技的应用。作为技术社区中活跃的参与者,O’Reilly的发展充满了对创新的倡导、创造和发扬光大。

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
# 嵌入式系统设计与实践 ## 【One-Line Pitch】 A practical, battle-tested guide to embedded systems engineering—covering architecture, hardware debugging, interrupts, communication protocols, and performance optimization—ideal for working engineers and serious hobbyists who want to move beyond toy projects to production-grade embedded software. ## 【Book Arc】 - **Opening (~0%–8%)**: Establishes the core philosophy—embedded systems are like interlocking puzzles requiring flexibility throughout their lifecycle. Introduces architecture design from block diagrams, emphasizing modularity, encapsulation, and designing interfaces that hide implementation details. The key insight: identify what will change and design interfaces accordingly. - **Early (~8%–25%)**: Dives into practical hardware fundamentals—reading datasheets strategically (skip the 88% of ARM manual you don't need), using development kits effectively, and building a debugging toolbox. Covers oscilloscope basics, board handling safety, and the importance of understanding your specific processor's user manual rather than generic architecture docs. - **Early–Middle (~25%–42%)**: Explores core embedded patterns: GPIO manipulation through register access, debouncing buttons with counters and sampling, timer configuration (prescalers, compare registers, actions), and the classic interview question about `volatile`—why it's essential when polling hardware registers. Introduces state machines as a way to keep complex systems organized. - **Middle (~42%–58%)**: Covers interrupts in depth—context saving, latency, critical sections, and the dangers of interrupt nesting. Explains system ticks for timekeeping, watchdog timer best practices (and common anti-patterns that defeat their purpose), and introduces keypad matrix scanning and motor control basics (stepper vs. brushed DC). - **Late (~58%–75%)**: Moves to communication protocols—serial (UART/RS-232), I²C, SPI, and Ethernet/WiFi considerations. Includes the circular buffer pattern with atomic operations, versioning and checksums for robustness, and bootloader design for field updates. Discusses memory mapping and linker scripts for code placement. - **Ending (~75%–83%)**: Focuses on optimization—reading linker map files to understand memory usage, function vs. macro trade-offs, stack vs. global variable decisions, and profiling techniques including sampling profilers that avoid bias from periodic interrupts. Covers reducing math in loops and byte-level optimizations for 8-bit processors. ## 【Key Takeaways】 - **Architecture diagrams are living documents** (Early): Start from schematics, identify modules and their interfaces, and design for change—the flash chip, display, or communication method will likely change before release. Encapsulation lets you swap implementations without ripple effects. - **Read datasheets like a tortoise, not a hare** (Early): Skim the overview, dive deep only into sections relevant to your current task, then re-read the feature summary once you understand the device. Get the processor-specific user manual, not the generic ARM one—88% of it is irrelevant. - **`volatile` is non-negotiable for hardware access** (Middle): Without it, the compiler may optimize away your register polling loop entirely. This is the single most common embedded interview question because it's the single most common real-world bug. - **Debouncing requires deliberate design** (Early): Sample button states multiple times (e.g., 5 consecutive reads at 100Hz) and weigh the cost of errors against the cost of better filtering. Response time matters—250ms feels slow, 50ms feels good. - **Keep interrupts short and critical sections safe** (Middle): Interrupt latency costs processor cycles—a 10-cycle latency at 100Hz wastes 10% of CPU. Disable all interrupts in critical sections (not just specific ones) to avoid priority inversion, and beware nested disable/enable calls that leave code unprotected. - **Watchdogs fail when serviced in the wrong places** (Middle): Don't service the watchdog in a timer interrupt or delay function—a dead loop with a delay will still reset it. Place the service call where it proves the main flow is actually progressing. - **Circular buffers need atomic index updates** (Late): The write index increment must be a single instruction—use `uint16_t` on 16-bit processors, but verify on 8-bit. Reject data on overflow rather than silently corrupting the buffer. - **Linker map files are optimization goldmines** (Ending): Configure your build to output a `.map` file, learn to read it, and compare versions after changes. Find the largest variables and functions first—shrinking a 200-byte array beats optimizing a 12-byte one. ## 【Reading Tips】 - **Skim the architecture chapters (1–2)** if you're already working on existing code—but do read the section on drawing diagrams from code files and directories; it's practical for reverse-engineering legacy systems. - **Deep-read Chapter 4 (GPIO, timers, debouncing)** and Chapter 5 (interrupts, state machines)—these are the heart of embedded programming and the source of most bugs. The `volatile` discussion alone is worth the price. - **The debugging and hardware chapters (3)** contain practical wisdom (oscilloscope trigger setup, board handling) that's easy to skim but worth remembering when you're in the lab at 2am. - **Chapter 8 (optimization)** is best read when you actually have a performance problem—the map file reading and profiling techniques are reference material, not bedtime reading. - **Watch for the author's interview anecdotes** scattered throughout—they reveal common failure modes and what experienced engineers actually care about. ## 【Coverage Limits】 Excerpts cover roughly the first 83% of the book; the final chapters on power reduction and additional optimization techniques are only partially represented. Specific code examples are abbreviated, so readers should consult the full text for complete implementations. ##
Excerpt 1
书名: 嵌入式系统设计与实践 (OReilly精品图书系列) ((美)怀特(White, E.))(Z-Library) 作者: (美)怀特(White, E.) 《O'Reilly精品图书系列:嵌入式系统设计与实践》深入分析嵌入式系统的架构设计步骤和架构设计模式。介绍嵌入式系统中独有的设计模式,如环形缓冲区、中...
View in text
Excerpt 2
很复杂,可以将多个方框合为一 个,然后在另一个图中将其展开。 你采用什么样的风格画图取决于哪个让你感到比较得心应手。也 许在你最终决定采用某个之前,你需要尝试稍许多一点的不同方法。 些测试代码。而且,这些测试往往是生产测试的一部分,在生产过程 中用来检查电路板的功能。 怎么知道需要写哪些测试呢?这个需要从对处理器...
View in text
Excerpt 3
1->DATA&=~(1<<2);//IO1_2 low IOWrite函数,就必须有一个变量在高电平和低电平之间切换。而使用 IOSet和IOClear,就可以省掉这个变量,并在主循环中检查需要调用 哪个函数。另外一种选择就是使用函数IOToggle将IOSet和IOClear隐 藏。 异或 异或(XOR)从某...
View in text
Excerpt 4
寄存器来说,如果中断发生在这个过 程的任何两步之间,这个多步过程就可能产生问题。为了防止这种竞 5.3.2 保存上下文 中断请求发生以后(在设置了中断并触发事件发生以后),在找 到合适的ISR并调用以前,处理器将它当前所处的状态保存起来。像书 签保存阅读的位置一样,处理器将它的上下文保存到栈(参考8.2.1 节)...
View in text
Excerpt 5
RT)来实现的某种设备。这样说可能没有太多的帮助,不 是吗?让我们先定义一些术语,然后再看看最为通用的串行通信方 法。 有些UART也实现了类似RS-232的通信协议,这是计算机上串口的 默认通信协议。 注意:即使是高端的因特网路由器常常也会有一个用于配置和调 试的串口。虽然实现成本低廉,但是串口就像一个内六星的...
View in text
Excerpt 6
-1)。 例8-1:求3个数中最小值的算法 if a<b, if a<c,return a else,return c else, if b<c,return b else,return c 我尝试了一些不同的实现方法。首先,我将代码写在main函数 中,编译完后得到以字节表示的代码大小基线(假设其他部分自动编...
View in text
Excerpt 7
直让它保持运行状态要好。 图 10-2 基于中断的代码流程图 中断可以由某个外设产生,告诉处理器注意(如模数转换器完成 了数据转换,需要处理器读取结果数据并开始下一轮转换)。在另一 些系统中,中断可以由用户按下按钮时触发,或者传感器采样超过临 界值时产生。中断还可以由内部产生,如定时器。 在中断触发的时候,处理器...
View in text
Tags
AI categories
Programming LanguageCode
ISBN: 7111415841
Publisher: O'Reilly Media
Publish Year: 2018
Language: English
Pages: 500
File Format: PDF
File Size: 4.7 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…