Page 360 - Programming Microcontrollers in C
P. 360

Other MC68HC16 Considerations       345

                              The data array starts out empty, and the coefficients are each 0x100.
                          The output is as you would expect—it starts and increases linearly
                          from 0 to 64 in the first 32 samples. The output then remains at 64 until
                          the end of the test. This linear ramp is exactly what one would expect
                          when sending a step function into the constant weighting function.
                              There is one important point to be found in this program. It was
                          stated earlier that the programmer should attempt to keep the code in
                          C whenever possible. In the above case, we introduced a rather simple
                          function in assembly language. The fact that the program was a func­
                          tion, and it was necessary to use a large memory model, the code
                          required to handle the data as it was passed into the function is much
                          longer than you would expect. Also, the implied C code in preparing
                          the machine for the function call and the handling of the extension
                          registers in the main program makes the overall program larger than
                          expected. Unfortunately, it is not possible to access the DSP with C,
                          so if you wish to do DSP operations, assembly language access is all
                          that you can use.

            Other MC68HC16 Considerations

                              The discussion in this chapter has been dedicated to the
                          MC68HC16 microcontroller. Of course, there are components of this
                          microcontroller that are not covered in this chapter. No attempt was
                          made to outline the access to the analog-to-digital converter, several
                          features of the general purpose timer, the serial peripheral interface,
                          or the static RAM. However, the programs shown here do cover
                          enough of the part to demonstrate that the on-board peripherals can
                          be accessed from the C language. In the approach used, the header
                          files contain all of the bit field definitions needed to access any bit or
                          bit field in any control register in the part.
   355   356   357   358   359   360   361   362   363   364   365