Page 317 - Programming Microcontrollers in C
P. 317

302    Chapter 6  Large Microcontrollers

                              Another potential problem occurs when two internal modules
                          are assigned the same priority level. In this case, a second level of
                          arbitration is set up to choose among these several modules, in the
                          event that more than one module requests an interrupt at the same
                          time. The module control register of each module has a field called
                          IARB. This 4-bit field is assigned by the programmer and it is an
                          arbitration level that will be applied when the processor must select
                          between two equal priority interrupts that occur simultaneously. The
                          interrupting module with the largest IARB value will be given con­
                          trol of the processor. The IARB field can contain values from 0 to
                          15. When the module is being used, its IARB ield must be assigned
                                                                      f
                          a non-zero value, and no two modules can contain the same IARB
                          value. The code line

                   GPT_MCR.IARB=GPT_IARB;/* pick an IARB for the Timers */

                          places a value 5 into the IARB of the general purpose timer.
                              The interrupt level 6 is assigned to the GPT by the code line

                   ICR.IRL=GPT_IRL;             /* interrupt level 6 */
                          and the vector base address is assigned a value of 40 by the code line

                   ICR.VBA=GPT_VBA;             /* vectors start at 0x40 */

                              The means by which the vector assignment is accomplished in
                          the GPT is different from that for the remaining modules in the
                          MC68HC16. For the GPT, a 4-bit vector base address field is found
                          in the interrupt configuration register. A vector is an 8-bit value.
                              The vector assignment is accomplished when the value placed in
                          the VBA field of the ICR is used as the high nibble of an 8-bit num­
                          ber. The lower four bits are specified by the contents of Table 6-2.
                          There you will note that the vector address of OC3 is at 0xV6. When
                          the contents of the VBA field is 4, then the vector for OC3 is 0x46.
                          The vector address is twice the value of the vector or 0x8c in this
                          case. That is the reason that the address OC3_Isr is placed in the
                          address 0x8c in the vector initialization routine.
                              You will note that each interrupt in the timer will be assigned a
                          vector with the most significant nibble of the value placed in the
                          VBA field of the ICR. There is a prearranged priority among these
                          several interrupts. One interrupt can be moved to the highest priority
                          among the several timer interrupts if desired. The priority adjust bits
   312   313   314   315   316   317   318   319   320   321   322