Page 300 - Programming Microcontrollers in C
P. 300

Summary      285

                              There are three input/output routines that have been written for
                          this program. These routines, putchar(),  dprint(), and
                          do_crlf(), can be used with other systems with a serial input/
                          output system. The Cosmic compiler does provide the usual I/O
                          routines like printf(), gets(), puts(), etc. It does not provide
                          a basic putchar() and getchar() which is used by all of these
                          library routines. The reason that these routines are not provided by
                          the compiler is the wide variety of what the programmer will want to
                          implement with the built-in SCI ports on the MC68HC11 family.
                          The putchar() shown above will work in most instances. The
                          dprint() routine is a recursive routine that converts an integer
                          into an ASCII string and sends it to the SCI port.
                              There is one final modification to the program. In the last lines of
                          the PWM timer routine, count1 and tick1 are processed to set
                          tick1 to be TRUE each second. This flag is then used to control the
                          writing of the motor speeds to the terminal screen.

            Summary

                              There has been no attempt to work all of the peripherals on the
                          MC68HC11. The various peripherals are similar to those on the other
                          parts that we have discussed in other chapters or will discuss later.
                          We have seen several timer applications both in the MC68HC11 and
                          in the MC68HC05. We will see other timer applications in the
                          following chapters.
                              We have seen detailed use of the output compare timer subsystem
                          to make a pulse width modulation digital-to-analog converter system.
                          Depending on the program, the system allowed excellent performance
                          in either short on times or maximum on times, but not both without the
                          addition of a significant amount of code. We will see a system in the
                          next chapter that provides excellent performance for both minimum
                          and maximum on times. This performance is not a limitation of the
                          MC68HC11, merely a limitation of the programs presented so far.
                              The input capture subsystem has been used to measure motor
                          speed in a simple DC motor controller. This system used a primitive
                          reed switch to measure the rotation of the motor shaft, and the
                          performance of the switch was poor. A debouncing system was
                          developed that prevented input captures to occur for a specified time
                          after the first input was detected. This approach uses an output
   295   296   297   298   299   300   301   302   303   304   305