Page 322 - Programming Microcontrollers in C
P. 322

Cosmic MC68HC16 Compiler        307

                     ;
                     .end
                              In the above code, the EK, XK, and ZK registers are initialized
                          to the value found in .__bss__ . The initial value of YK is set to
                          0xf. The Y register will be used by the compiler to contain an offset
                          to all of the data contained in the control registers found in the header
                          files. Therefore, the YK register must be set to the top memory block
                          in the computer memory space.


            Using the SCI Portion of the Queued Serial Module
                              The queued serial module (QSM) contains two parts. The first is a
                          convenient serial communications interface (SCI) which provides
                          asynchronous serial communications that is used between comput­
                          ers and other devices. The remainder of the QSM is a queued serial
                          peripheral interface that is often used for high-speed communica­
                          tions between computers and peripheral devices. This interface is
                          strictly synchronous.
                              Let’s examine an interface between the program and a terminal
                          much like that found in Chapter 5. Here, the interface will simply
                          read in a number from the screen and put that number into the
                          pwm_count value for the PWM program. With this operation in
                          place, the operator can type in a value and change the PWM on time
                          at will. Listing 6-3 contains a program that will accomplish this end.
                   #include “hc16.h”
                   #include “gpt.h”
                   #include “sim.h”
                   #include “qsm.h”
                   #include “defines.h”

                   #define PERIOD 0x1000
                   #define ON_TIME       0x0800
                   #define SIM_IARB  4
                   #define GPT_IARB  10
                   #define GPT_IRL       6
                   #define GPT_VBA       5
                   /* set the baud rate=fclock/32*baud_rate */
                   #define BAUD_SET        (32768*512)/(32*38400)

                   /* function prototypes */
                   @port void OC3_Isr(void);
   317   318   319   320   321   322   323   324   325   326   327