PIC 16f877 header file

Discussion in 'Embedded Systems and Microcontrollers' started by Janeera, Mar 10, 2011.

  1. Janeera

    Thread Starter New Member

    Mar 9, 2011
    4
    1
    I am programing PIC using MPLAB Sim. but I need the header file pic.h for pic 16f877. can anyone give me the code :confused:?

    I have the other 3 header files- pic_lcd8.h, pic_serial.h and pic_adc.h

    This is my program... to display ecg, pressure, pulse, respiration rate.

    Code ( (Unknown Language)):
    1.  
    2. #include<pic.h>
    3. #include"pic_lcd8.h"
    4. #include"pic_serial.h"
    5. #include"pic_adc.h"
    6.  
    7. #define pulse1 RB1
    8. //#define pulse2 RB2
    9.  
    10. unsigned char i,j,v[10],f,g,h,re,time=0,sec=0,aa=0,bb=0,pul,sec1=0,pulse,count,count1,beat,Temp;    
    11. int pressure;
    12.  
    13. void main()
    14. {
    15.     TRISC=0xC0;
    16.     TRISD=0x00;
    17.     TRISB=0x03;
    18.     lcd8_init();
    19.     Serial_Init(9600);
    20.    
    21.     GIE=1;                        
    22.     PEIE=1;
    23. //    INTE=1;
    24. //    INTEDG=1;
    25.     TMR1IE=1;
    26.     TMR1H=60;
    27.     TMR1L=235;
    28.     T1CON=0X00;
    29.     TMR1ON=0;
    30.     Receive(0);
    31.     lcd8_display(0x80," Cardiopulmonary ",16);
    32.     lcd8_display(0xc0," Activity Monitor ",16);
    33.     delay(65000);delay(65000);
    34.     lcd8_display(0x80,"Pre:     R:      ",16);
    35.     lcd8_display(0xc0,"E:    P:    S:  ",16);
    36.     delay(65000);delay(65000);
    37.  
    38.     while(1)
    39.     {
    40.         TMR1ON=1;    
    41.         Temp=Adc8_Cha(0);//value reading for temperature
    42.         pressure=Adc8_Cha(1);//value reading for pressure
    43.     //    if(!pulse2 && !bb)    { bb=1;     }
    44.     //    if(pulse2 && bb)    { bb=0; pulse++; }
    45.    
    46.         if(!pulse1 && !aa)    { aa=1;     }
    47.         if(pulse1 && aa)    { aa=0; pul++; }
    48.  
    49.         lcd8_decimal2(0xce,sec);
    50.         lcd8_decimal3(0x84,pressure);    
    51.         lcd8_decimal3(0x8b,pul);
    52.         lcd8_decimal3(0xC2,Temp);    
    53.         lcd8_decimal3(0xC8,pulse);
    54.    
    55.         if(sec>59)
    56.         {
    57.             delay(65000);delay(65000);
    58.             TMR1ON=0;
    59.             sec=0;
    60.             pul=pulse=0;
    61.         }
    62.        
    63.    
    64.     }
    65.  
    66. }    
    67.          
    68. void interrupt ser_int(void)
    69. {
    70.     if(RCIF) //reciever interrupt flag
    71.     {
    72.         RCIF=0;
    73.         v[i]=RCREG;i++;        
    74.     }
    75.     if(INTF)/interrupt flag
    76.     {
    77.         INTF=0;
    78.         pulse++;
    79.     }
    80.     if(TMR1IF==1)
    81.     {
    82.         TMR1ON=0;
    83.         TMR1IF=0;
    84.         count1++;
    85.         if(count1>=20){sec++;count1=0;}
    86.         TMR1H=60;
    87.         TMR1L=235;
    88.         TMR1ON=1;
    89.     }
    90.    
    91. }
    92.  
    93. [/i]
     
    Last edited by a moderator: Mar 15, 2011
    karthik_dm likes this.
  2. someonesdad

    Senior Member

    Jul 7, 2009
    1,585
    141
    What compiler are you using? If you e.g. downloaded and installed the C18 compiler from Microchip, that include file should already be present.
     
  3. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    A bit more information from you would help!
    If you are programming for a PIC16F877 you obviously can't be using the C18 compiler so which compiler are you using? Basic information like that will get you a much better response to your query.
    Also when posting code go into "Advanced" mode and wrap the code in code (#) tags so that any formatting gets preserved and makes the code easier to read.

    As a wild guess I think you might be using HitechC in which case you don't have to include the pic.h file. Everything gets done through the htc.h file so what you need to do is place "#include <htc.h>" as your first #include statement followed by your other include statements. If the header pic.h is needed it will get called from the htc.h header file.
    Incidental the pic.h file along with htc.h and various other header files is on your PC amongst the HiTech program files under the "include" subdirectory.
     
    Janeera likes this.
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    If you are using the HI-Tech C compiler. You should read the quickstart.pdf. In the compiler install folder under the docs dir. That Should be something like this path
    C:\Program Files\HI-TECH Software\PICC\9.81\docs
     
  5. Janeera

    Thread Starter New Member

    Mar 9, 2011
    4
    1
    Last edited: Mar 14, 2011
  6. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    The question was which compiler are you using not which IDE, MPLAB is an IDE and it supports many different compilers and programming languages.
    Header files are very much compiler specific so if you are using the cc5x compiler those files will be fine but if you are using any other compiler then those files will not work.
     
  7. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Your code looks very like HI-Tech C hence the header file from cc5x will not do you any good. Your program will be a nightmare do find out of. If you just uncritical use any code found on internet. And include it in your project
     
  8. karthik_dm

    Member

    Oct 16, 2008
    27
    0

    Hi bro, i'm doing the same ECG hardware using PIC16F877A, for that i need "pic_lcd8.h"
    "pic_serial.h"
    "pic_adc.h"
    Kindly help me with that files if you have..
    Thanks....
     
Loading...