Hardware Reference
In-Depth Information
4.13 Summary
Experience shows that when designing a complicated embedded system, designers spend a
smaller percentage (10 to 20%) of their time on hardware design but a much higher percentage
(80 to 90%) of their time on software development and debugging. Since it takes much longer to
get the software designed right, it is important for us to learn the right way for software
development. The top-down design with hierarchical refinement approach is considered the most
effective system development methodology. For example, using the top-down design with hierar-
chical refinement approach, the two-tone siren can be generated in the following manner:
In the first iteration, the algorithm for generating the two-tone siren can be outlined as follows:
Iteration 1
Step 1
Generate a 500-Hz periodic square wave for half of a second.
Step 2
Generate a 250-Hz periodic square wave for half of a second.
Step 3
Go to step 1.
In the second iteration, we need to work out the details for generating 500-Hz and 250-Hz
periodic square waves for half of a second.
Iteration 2.1 (generation of 500-Hz square wave)
The period of a 500-Hz square wave is 2 ms, and therefore there are 250 periods of the
waveforms in half of a second.
Step 1
lpcnt1
250
Step 2
Pull the PT5 pin to high.
Step 3
Wait for 1 ms.
Step 4
Pull the PT5 pin to low.
Step 5
Wait for 1 ms.
Step 6
lpcnt1
lpcnt1 2 1;
Step 7
If (lpcnt1 ? 0), go to step 2; else, continue to the next step.
Iteration 2.2
The period of a 250-Hz square wave is 4 ms, and therefore there are 125 periods of the
waveforms in half of a second.
Step 1
lpcnt1
125
Step 2
Pull the PT5 pin to high.
 
Search WWH ::




Custom Search