Page 362 - Programming Microcontrollers in C
P. 362

Chapter 7










            Advanced Topics in Programming


            Embedded Systems (M68HC12)



                              During the past few years, we have seen an unbelievable
                          proliferation of embedded systems products. Devices that could only
                          be imagined ten years ago are commonplace today and their very
                          existence demonstrates the importance of C programming for small
                          microcontrollers. Let’s take a look at one such application and see
                          how easily you can develop rather complicated applications on
                          microcontrollers.
                              Throughout this text, much emphasis has been placed on the
                          construction of small functions and then integrating these functions
                          into a working package. This approach is about the only way that
                          you can really hope to create a complicated piece of firmware in a
                          sensible time. My early projects would always start with careful design
                          of the whole project, partitioning of the project into sensible modules,
                          design of each module, writing the code for each module, integration
                          of the whole project and then, after cleaning up syntax errors, I’d
                          begin to test the whole program. What a disaster! These programs
                          would never work and there would be no hope of ever getting the
                          package to run as a unit.
                              As I gained experience, I found that the top-down approach I
                          used was probably satisfactory if I tempered the integration of the
                          system. Today, I start with a careful design for the whole system.
                          This design is partitioned into constituent components. At that point,
                          another look at the design is in order to see if the existing components
                          can be further reduced into sensible components. At that point, the
                          lowest-level components are coded. Often these functions are so
                          simple that they work when first tested. Whenever there is a required



                                                                                       347
   357   358   359   360   361   362   363   364   365   366   367