PIC 16F877 c code

Discussion in 'Programmer's Corner' started by Janeera, Mar 14, 2011.

  1. Janeera

    Thread Starter New Member

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


    can someone please explain this MPLAB IDE v8.00 PIC C code to me?
    It is a program using PIC 16F877 to get the data from an ECG, respiration rate, pressure and heart rate circuit and display the output in an LCD and further serial communication is done via zigbee to view it on a laptop.
     
    Last edited: Mar 14, 2011
  2. debjit625

    Well-Known Member

    Apr 17, 2010
    790
    186
    Which part of the program,or if you are asking about the full program then I am sorry you need to learn about PIC and C try some tutorial or books.Have a google search....it may help

    Good Luck and welcome to AAC
     
Loading...