Page 111 - The Art of Designing Embedded Systems
P. 111
98 THE ART OF DESIGNING EMBEDDED SYSTEMS
Whenever you complete a function, append the incremental size of
the executable to the spreadsheet. Figure 5- 4 shows an example, including
each function, with estimated and actual LOC counts, and compiled sizes.
Any idiot-r at least any idiot with an engineering degree-can
then write an equation that creates an average size of an LOC in bytes, and
another that predicts total system size based on estimated LOC.
Make sure your calculations do not include the bare system skele-
ton-the C startup code and a null main() function-since the first line of
C brings in the runtime package.
RAM Diagnostics
Beyond software errors lurks the specter of a hardware failure that
causes our correct code to die, possibly creating a life-threatening horror,
or maybe just infuriating a customer. Many of us write diagnostic code to
help contain the problem. Much of the resulting code just does not address
failure modes.
Obviously, a RAM problem will destroy most embedded systems.
Errors reading from the stack will surely crash the code. Problems, espe-
cially intermittent ones, in the data areas may manifest bugs in subtle ways.
Often you’d rather have a system that just doesn’t boot, rather than one that
occasionally returns incorrect answers.
Module Est LOC Act LOC Size
Skeleton 300 3 10 21,123
RTOS 3423 1 1,872
TIMER-ISR 50 34 534
ATOD-ISR 75 58 798
TOD 120 114 998
PRINT-E 80 98 734
COMM-SER I90 I I I
RD-ATOD 40
Bytes/LOC 4.01
Est Size 36580

