三相功率计算器 — 公式
## Estimating Stack Size for Embedded Systems
Stack overflow is a common and dangerous bug in embedded systems. Proper sizing prevents crashes.
### Formula
**Base Stack = Max Call Depth x Avg Frame Size**
**ISR Stack = Interrupt Levels x ISR Frame Size**
**Recommended = (Base + ISR) x (1 + Safety Margin)**
The safety margin accounts for worst-case alignment, compiler-generated temporaries, and unforeseen call paths. A 25% margin is typical for production systems.
Stack overflow is a common and dangerous bug in embedded systems. Proper sizing prevents crashes.
### Formula
**Base Stack = Max Call Depth x Avg Frame Size**
**ISR Stack = Interrupt Levels x ISR Frame Size**
**Recommended = (Base + ISR) x (1 + Safety Margin)**
The safety margin accounts for worst-case alignment, compiler-generated temporaries, and unforeseen call paths. A 25% margin is typical for production systems.
计算示例
8-deep call stack, 32-byte frames, 2 interrupt levels at 64 bytes each, 25% safety.
- Base stack: 8 x 32 = 256 bytes
- ISR stack: 2 x 64 = 128 bytes
- Total raw: 256 + 128 = 384 bytes
- With 25% margin: 384 x 1.25 = 480 bytes