PROGRAMMING YOUR EPROM HC11

Before programming your EPROM HC11 you will first have to modify your code so it will work properly in EPROM. After the necessary changes have been made to your code, you will put your EPROM HC11 into your EVBU and program it using PCBUG11. Do the following:

  1. Get your program working in your BUFFALO HC11.

  2. Remove the interrupt vector code from your program. For example, if you use an Input Capture 1 interrupt service routine called ic1_isr(), remove the two lines
             TIC1_JMP = JMP_OP_CODE;
             TIC1_VEC = ic1_isr;
    

  3. Copy the file e:\icc11\examples\vectors.c into your directory. Edit the file vectors.c, adding the names of your interrupt service routines at the appropriate locations. For example, for your ic1_isr(), find the line
             0,          /* TIC1 */
    
    and change it to
            ic1_isr,     /* TIC1 */
    

    Also, near the top of the file vectors.c, just below the line

            extern void _start();   /* entry point in crt11.s */
    
    add lines for your interrupt service routines. For example, for your ic1_isr(), add the line
            extern void ic1_isr();
    

  4. If your program uses the RS-232 port (e.g., uses the printf() function), you will have to initialize the SCI because BUFFALO no longer will do this. Add the following lines to the initialization part of your program:
            BAUD = 0x30;        /* 9600 Baud */
            SCCR1 = 0x00;
            SCCR2 = 0x0c;       /* Enable SCI transmitter and receiver */
    

  5. If you have variables you want to be initialized, and the variables will not change during execution, delare them to be of type const. For example, the T-Bird taillights:
        const unsigned char tbird[] =
            {0x00,0x08,0x0c,0x0e,0x0f,0x00,0x10,0x30,0x70,0xf0};
    
    The const tells the compiler to put these numbers in the code section, which will be in EPROM, so they will be there permanently, but you will not be able to change them.

  6. If you have variables you want to be initialized, and the variabes will change during execution, you cannot initialize the variables when you define them, but will have to do it in the program. For example, if your program has the following in it:
        int i=0;
    
        main()
        {
            ...
    
    change it to:
        int i;
    
        main()
        {
            i = 0;
            ...
    

  7. A function cannot use an initialized static variable. If a function has the following:
        void foo (void)
        {
            static int i=0;
    
            if (i < 0)
            ...
    
    change the static variable to a global variable and initialize it in main(). You may have to invent a unique name for the variable so it does not conflict with another variable name. For example:
        int foo_i;
        
        main()
        {
            foo_i = 0;
            ...
        }
        void foo(void)
        {
            if (foo_i < 0)
            ...
    

  8. Compile your program telling the compiler to include the file vectors.c, to put your code in EPROM at 0xd000, and to put your interrupt vectors at 0xffd6. For example, if the name of your program is prog.c, use the following line to compile it.
       icc11 -l -o prog.s19 prog.c vectors.c -btext:0xd000 -bdata:0x0100
             -binterrupt_vectors:0xffd6 -d_stack:0x0fff
    

  9. Make sure power is turned off to your EVBU. Remove the BUFFALO HC11 from your EVBU and put in the EPROM HC11.

  10. To program the EPROM, follow the instructions on pages 1-1, 1-2 and 1-4 of blue handout labeled S68HC11EVBU/L1 that came with your EVBU. Follow these instructions exactly! You will be applying +12 V to your HC11 in order to program it. If you do not follow the instructions, you will probably destroy your EPROM HC11.


Bill Rison, <rison@ee.nmt.edu >