Page 428 - Programming Microcontrollers in C
P. 428

Handling Interrupts   413

                              The next three functions can be used to send and receive strings
                          through the serial port. To use puts(), you use a string argument.
                          This function will send characters from the string until it finds a zero
                          value in the string. The get string functions perform similar to the
                          standard fgets() function. The difference between gets() and
                          getse() is that getse() echoes the characters read in to the serial
                          output. Otherwise these two functions are identical. You pass gets()
                          two parameters. The first is a pointer to a character array and the second
                          is the dimension of this array. As characters are read into the program,
                          they are stored in the character array. The string input is terminated by
                          either a ‘\n’ or a ‘\r’ character. The input will also be terminated
                          when the input character string is one less than the size of the array size.
                          When termination is detected, the input is terminated with a character
                          zero, making the data a string. The return to the calling program will be
                          –1 in the event that the character array was completely filled. Otherwise,
                          the return is the number of characters entered into the character array.
                              The function gets() reads data from the serial port with the
                          getch() function. This input does not echo the data entered.
                          getse() uses the getchar() to read the data in. getchar()
                          always echoes the input data to the serial output.
                              The above routines were separated into a series of individual
                          functions, which were combined into an archive library file. This file
                          is found on the CDROM under the name libserio.a. This file
                          can be linked during the linking operation like any other library file.


            Handling Interrupts
                              All of the onboard peripherals found on the MMC2001 that need
                          access to interrupts are set up to use the core processor Auto Vector
                          capability. Shown in Table 8-1 is a copy of the interrupt vector table.
                          The vector table is placed at a location called the VBA, Vector Base
                          Address, when the chip is initialized. You will note that the table is
                          0x200, two hundred hex bytes, long. The vector numbers are
                          consecutive. The vector addresses move in steps of 4 and are usually
                          dealt with as hexadecimal values. This table must be filled in some
                          way when the program is initialized. Each vector will contain the address
                          of the function executed when the corresponding exception occurs.
                          Most of these vectors are self-explanatory. Of import here is the Fast
                          Interrupt Autovector location. Note that the offset of this vector is 0x2c.
   423   424   425   426   427   428   429   430   431   432   433