Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

need help in interfacing two sensors to P18F4550

Status
Not open for further replies.

ravindrareddy2131

Newbie level 4
Joined
Jul 12, 2011
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,370
hi everyone,
i am interfacing temperature sensor to AN0 and humidity sensor to AN1 inputs of P18F4550 microcontroller. i had written the program in MPLAB IDE. am getting only humidity value in hyperterminal but the temperature loop is not executing. Here is my program. could any one please help me..thank you
#include<p18f4550.h>
#include<usart.h>
#include<delays.h>


#pragma config FOSC=HS
#pragma config BOR=OFF
#pragma config PWRT=OFF
#pragma config WDT=OFF, DEBUG=OFF
#pragma config LVP=OFF
#pragma config MCLRE=ON
#pragma config PBADEN=OFF
#pragma config ICPRT=OFF


void sertx(unsigned int);
void MSDelay (unsigned int);
void chk_ISR(void);
void INT0_ISR(void);



#pragma interrupt chk_ISR
void chk_ISR(void)
{
if(INTCONbits.INT0IF==1)
INT0_ISR();
}

#pragma myhipri_int=0x08;
void myhipri_int(void)
{
_asm
goto chk_ISR
_endasm
}
#pragma code


void main(void)
{
unsigned char LB,HB,BT,T1,T2;
TRISC=0;
TRISD=0;
ADCON0=0x09;
ADCON1=0x45;
TRISBbits.TRISB0=1;
TRISCbits.TRISC6=0;
TXSTA=0x20;
SPBRG=31;
TXSTAbits.TXEN=1;
RCSTAbits.SPEN=1;
INTCONbits.INT0IF=0;
INTCONbits.INT0IE=1;
INTCONbits.GIE=1;
while(1)
{
ADCON0bits.GO=1;
while(ADCON0bits.DONE==1)
LB=ADRESL;
HB=ADRESH;
BT=HB;
H1=(BT/10)+48;
H2=(BT%10)+48;
sertx('H');
sertx('M');
sertx('D');
sertx('T');
sertx('Y');
sertx(H1);
sertx(H2);
MSDelay(250);
}
}
void INT0_ISR(void)
{
unsigned char LB,HB,HD,H1,H2;
ADCON0=0x01;
ADCON1=0x45;

while(1)
{
ADCON0bits.GO=1;
while(ADCON0bits.DONE==1)
LB=ADRESL;
HB=ADRESH;
HD=HB;
T1=(HD/10)+48;
T2=(HD%10)+48;
sertx('T');
sertx('E');
sertx('M');
sertx('p');
sertx(T1);
sertx(T2);
INTCONbits.INT0IF=0;
}
}

void sertx(unsigned int C)
{
while(PIR1bits.TXIF==0);
TXREG=C;
}


void MSDelay (unsigned int itime)
{
unsigned int i;
unsigned int j;
for(i=0;i<itime;i++)
for(j=0;j<135;j++);
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top