PIC 16F877 c code

Thread Starter

Janeera

Joined Mar 9, 2011
4
Rich (BB code):
#include<pic.h>
#include"pic_lcd8.h"
#include"pic_serial.h"
#include"pic_adc.h"

#define pulse1 RB1
//#define pulse2 RB2

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;	
int pressure;

void main()
{
	TRISC=0xC0;
	TRISD=0x00;
	TRISB=0x03;
	lcd8_init();
	Serial_Init(9600);
	
	GIE=1;						
	PEIE=1; 
//	INTE=1;
//	INTEDG=1;
	TMR1IE=1;
	TMR1H=60;
	TMR1L=235;
	T1CON=0X00;
	TMR1ON=0;
	Receive(0);
	lcd8_display(0x80," Cardiopulmonary ",16);
	lcd8_display(0xc0," Activity Monitor ",16);
	delay(65000);delay(65000);
	lcd8_display(0x80,"Pre:     R:      ",16);
	lcd8_display(0xc0,"E:    P:    S:  ",16);
	delay(65000);delay(65000);

	while(1)
	{
		TMR1ON=1;	
		Temp=Adc8_Cha(0);//value reading for temperature
		pressure=Adc8_Cha(1);//value reading for pressure
	//	if(!pulse2 && !bb)	{ bb=1; 	}
	//	if(pulse2 && bb)	{ bb=0; pulse++; }
	
		if(!pulse1 && !aa)	{ aa=1; 	}
		if(pulse1 && aa)	{ aa=0; pul++; }

		lcd8_decimal2(0xce,sec);
		lcd8_decimal3(0x84,pressure);	
		lcd8_decimal3(0x8b,pul);
		lcd8_decimal3(0xC2,Temp);	
		lcd8_decimal3(0xC8,pulse);
	
		if(sec>59)
		{
			delay(65000);delay(65000);
			TMR1ON=0;
			sec=0;
			pul=pulse=0;
		}
		
	
	}

} 	
		 
void interrupt ser_int(void) 
{
	if(RCIF) //reciever interrupt flag
	{
		RCIF=0;
		v=RCREG;i++;		
	}
	if(INTF)/interrupt flag
	{
		INTF=0;
		pulse++;
	}
	if(TMR1IF==1)
	{
		TMR1ON=0;
		TMR1IF=0;
		count1++;
		if(count1>=20){sec++;count1=0;}
		TMR1H=60;
		TMR1L=235;
		TMR1ON=1;
	}
	}


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:

debjit625

Joined Apr 17, 2010
790
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
 
Top