Page 305 - Programming Microcontrollers in C
P. 305

290    Chapter 6  Large Microcontrollers

                          index registers (IX, IY, and IZ), and the EK register. All these regis­
                          ters except for the EK are 16 bits wide. The EK register is an extension
                          register that is used with the extended addressing mode. Any ex­
                          tended address calculation will result in a 16-bit number. The result
                          will be concatenated with the EK register to create a 20-bit address.
                          (The EK register has nothing to do with the E accumulator found in
                          the device.) The extension registers are named PK, SK, XK, etc. The
                          extension registers are usually set during initialization of the device,
                          and there is no need to change them during program operation. The
                          content of an extension register is a page pointer. The pages in this
                          case are each 65536 bytes long. Transition from one page to another
                          is automatic. For example, if an address is calculated for a jmp which
                          will pass program control to code in another page, the proper ad­
                          dress will be calculated for both base and extension register
                          automatically. The calculation will alter the contents of both the base
                          and the extension register without programmer concern.
                              The MC68HC16 family currently has the several internal modules
                          mentioned above, and it is planned that future versions of the part will
                          have more modules. This complexity has suggested that the arrange­
                          ment of the header file for the part be broken into several different
                          files: One file for the main processor, and several different header files,
                          one for each of the peripheral modules in the individual part. This
                          approach is shown in the HEADER/HC16HEADERS directory on
                          the CD-ROM. There you will find a header file named hc16.h along
                          with files named adc.h, gpt.h, sim.h, sram.h, and qsm.h.
                          When writing code for any specific module, you should include the
                          hc16.h file along with the proper files for the peripheral portions
                          needed. The hc16.h file must be included first because there are
                          items defined in this file needed by the other headers.
                              One major difference between the large and small devices is the
                          way the exception vector table is handled. Recall that, in the MC68HC11
                          family, all interrupt vectors are placed at the top of memory. With the
                          MC68HC16 family, the vector table is contained within the first 512
                          bytes of memory. Upon reset, the CPU16 core processor reads the first
                          four words of memory where it must find certain data for the opera­
                          tion of the program. The address 0 must contain a word whose least
                          significant 12 bits are the contents of the ZK, the SK and the PK reg­
                          isters when the part comes out of reset. The address 2 contains the
                          initial program counter, and the address 4 must contain the initial stack
   300   301   302   303   304   305   306   307   308   309   310