Page 165 - Programming Microcontrollers in C
P. 165

150    Chapter 4  Small 8-Bit Systems

                          16-bit machine and its peripheral components are nearly all different
                          from those found on the 8-bit machines. The M68HC16 is a superset
                          of the M68HC11; it will execute M68HC11 code, but the hardware
                          computer extensions and new peripheral components are significant.
                              To successfully program a microcontroller using a high-level lan­
                          guage, the programmer must be able to access various control and status
                          registers in the computer. The program must force the language to place
                          both program and data memory addresses in the proper locations in the
                          memory map. Vectors associated with interrupt service routines, and the
                          service routines themselves, must be handled directly by the program.
                          These tasks are difficult to accomplish with most high-level languages,
                          but C allows access to these things without extensions. However, most C
                          compilers for microcomputers have extensions that allow such special
                          features to be easily treated.
                                                                           1
                              The compiler used in this chapter is called C6805 . It was written to
                          support the M68HC05 family of devices. Be forewarned: some M68HC05
                          microcontroller instructions have no counterpart in the standard C lan­
                          guage. Special directives identify unique microcontroller characteristics
                          to the compiler. Listed in Table 4-1 below are nine assembly instructions
                          available to the 68HC05. These instructions have no equivalent C call.
                          They can be accessed as either a single instruction (all uppercase) or as
                          a function call as shown. The function call requires a pair of closed
                          parentheses to follow the name of the instruction.

                              Function                     Operation
                              CLC or CLC()                 clear carry bit
                              SEC or SEC()                 set carry bit
                              CLI or CLI()                 clear interrupt flag (interrupts on)
                              SEI or SEI()                 set interrupt flag (interrupts off)
                              NOP or NOP()                 no operation
                              RSP or RSP()                 reset stack pointer
                              STOP or STOP()               STOP instruction
                              SWI or SWI()                 software interrupt
                              WAIT or WAIT()               WAIT instruction

                              Table 4-1: Assembly Codes Directly Callable By C6805





            1  Byte Craft Limited, 421 King Street North, Waterloo, Ontario, Canada N2J 4E4
   160   161   162   163   164   165   166   167   168   169   170