how to create library

i have written a simple UART code, my project is entirely depends upon the serial comunnication.

i have to control 4 to 5 stepper motor and sensor, for which lot of subroutines r to be written,
i wanted to make small library which are classified into motor,uart,sensor codes .

now i have written a simple test code for my project, it is working fine when i write all the code in one C file.

when i am tring to modularized the code compiler shows 0 errors but 10 warnings.

*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  SYSTEM_INIT
    MODULE:  D:\SWAPNIL_PROJECT\S.O.A.M_30112010\CODE\VERSION2\SOAM_12112010\K
>> EIL2\TEST1.OBJ (TEST1)

*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  PORT_IO_INIT
    MODULE:  D:\SWAPNIL_PROJECT\S.O.A.M_30112010\CODE\VERSION2\SOAM_12112010\K
>> EIL2\TEST1.OBJ (TEST1)

*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  _UART1_TX
    MODULE:  D:\SWAPNIL_PROJECT\S.O.A.M_30112010\CODE\VERSION2\SOAM_12112010\K
>> EIL2\TEST1.OBJ (TEST1)

*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  UART1_INIT
    MODULE:  D:\SWAPNIL_PROJECT\S.O.A.M_30112010\CODE\VERSION2\SOAM_12112010\K
>> EIL2\TEST1.OBJ (TEST1)

*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  _DELAY
    MODULE:  D:\SWAPNIL_PROJECT\S.O.A.M_30112010\CODE\VERSION2\SOAM_12112010\K
>> EIL2\TEST1.OBJ (TEST1)

*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  SYSTEM_INIT
    MODULE:  D:\SWAPNIL_PROJECT\S.O.A.M_30112010\CODE\VERSION2\SOAM_12112010\K
>> EIL2\TEST1.OBJ (TEST1)
    ADDRESS: 0090H

*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  UART1_INIT
    MODULE:  D:\SWAPNIL_PROJECT\S.O.A.M_30112010\CODE\VERSION2\SOAM_12112010\K
>> EIL2\TEST1.OBJ (TEST1)
    ADDRESS: 0093H

*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  PORT_IO_INIT
    MODULE:  D:\SWAPNIL_PROJECT\S.O.A.M_30112010\CODE\VERSION2\SOAM_12112010\K
>> EIL2\TEST1.OBJ (TEST1)
    ADDRESS: 0096H
BL51 BANKED LINKER/LOCATER V6.11            11/15/2010  17:19:25  PAGE 3



*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _DELAY
    MODULE:  D:\SWAPNIL_PROJECT\S.O.A.M_30112010\CODE\VERSION2\SOAM_12112010\K
>> EIL2\TEST1.OBJ (TEST1)
    ADDRESS: 00A0H

*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  _UART1_TX
    MODULE:  D:\SWAPNIL_PROJECT\S.O.A.M_30112010\CODE\VERSION2\SOAM_12112010\K
>> EIL2\TEST1.OBJ (TEST1)
    ADDRESS: 00ADH

Program Size: data=17.0 xdata=0 code=198
LINK/LOCATE RUN COMPLETE.  10 WARNING(S),  0 ERROR(S)

please help me understand where i am going wrong

  • this is the code for the above error

    TEST1.C

    
    #include <c8051f340.h>
    #include <Uart1.h>
    #include "Deviceinit.h"
    
    /////////////////////////////////////////////////////////////////////
    unsigned char title[] = {'W','e','l','c','o','m','e'};
    
    char j;
    void main()
    {
       System_Init();
       UART1_Init ();
       Port_IO_Init();
    
       EA=1;
       EIE2      =0x02;        //Allow interrupt
    
       Delay(250);
    
      while(1)
       {
            for(j=0;j<7;j++)
            {
            Uart1_TX(title[j]); //display array
            }
       }
    }
    /*
    void CommValidation()
    {
       if (SBUF1 == '#')
       {
    
            Uart1_TX('#');
            Delay(50);
            Uart1_TX('#');
            Delay(50);
       }
    }
    
    */
    

    Deviceinit.c

    #include <c8051f340.h>
    
    
    
    void UART1_Init (void); void System_Init(void); void Port_IO_Init(void);
    unsigned char temp1;
    /**************************************************************** * *UART1 Beginning of the first *****************************************************************/ void UART1_Init (void) { SBRLL1 =0x8F; SBRLH1 =0xFD; //12M internal wave oscillating crystal 9600 special rate SCON1 =0x30; //Allowed to receive, ready to receive SMOD1 =0x6C; //8 data bits, no parity, one stop bit; SBCON1 =0x43; //Enable UART1, prescaler 1
    }
    void System_Init(void) { PCA0MD &= ~0x40; //Watchdog timer off OSCICN |= 0x03; //And the internal high-frequency oscillator is enabled by programming the oscillator frequency to run
    }
    /***************************************************************** * *Port initialization function *****************************************************************/
    void Port_IO_Init(void) { P0SKIP = 0xCF; P1SKIP = 0x3F; XBR0 = 0x01; XBR1 = 0x40; XBR2 = 0x01; }
    /***************************************************************** * Function: serial receive interrupt service function uart1 * Resources: register 3 * Export: Interput_Char *****************************************************************/ void UART1_Interrupt(void) interrupt 16 { if(SCON1&0x01) //RI1==1? { temp1=SBUF1;
    SCON1 &=0xFE; //RI1=0
    SBUF1=temp1;
    SCON1 &=0xFD; //TI1=0
    SBUF1 = 0x00; } }

    Uart1.c

    #include <c8051f340.h>
    
    char Uart1_TX(char c);
    void Delay (unsigned char delay);
    
    void Delay (unsigned char delay)
    {
            unsigned char uart_i;
            for(uart_i=0;uart_i<delay;uart_i++);
    }
    
    char Uart1_TX (char c)
    {
    
          while (!(SCON1 & 0x02));         // wait until UART1 is ready to transmit
          SCON1 &= ~0x02;                  // clear TI1 interrupt flag
          return (SBUF1 = c);              // output <c> using UART 1
    }
    
    
    

    Header files

    Deviceinit.h

    #ifndef _Deviceinit_h
    #define _Deviceinit_h
    
    extern unsigned char temp1;
    
    extern void UART1_Init (void);
    extern void System_Init(void);
    extern void Port_IO_Init(void);
    
    #endif
    
    

    Uart.h

    #ifndef _Uart_h
    #define _Uart_h
    
    
    extern unsigned char temp1;
    
    extern char Uart1_TX(char c);
    extern void Delay (unsigned char delay);
    
    #endif
    

More questions in this forum