Deexith Hasan
Advanced Member level 4
- Joined
- Oct 24, 2014
- Messages
- 111
- Helped
- 4
- Reputation
- 8
- Reaction score
- 3
- Trophy points
- 18
- Activity points
- 740
i have done a temp datalogger using pic..... got perfect result in proteus but not in my development board.....
PIC18F4520
20Mhz crystal
lm35 temp sensor....
HI tech compiler
i want to send ADRESH value to serial.....it will send ascii char like $?!~ ........in proteus its working...bu ton development board i got 00 first....but now not even 00
ADC working checked PORTD pins ....
PIC18F4520
20Mhz crystal
lm35 temp sensor....
HI tech compiler
i want to send ADRESH value to serial.....it will send ascii char like $?!~ ........in proteus its working...bu ton development board i got 00 first....but now not even 00
Code:
#include <htc.h>
unsigned char temp1=0;
unsigned char temp2=0;
unsigned char temp3=0;
unsigned char n=0;
void delay()
{
unsigned char i;
for(i=0;i<255;i++);
}
void serialwrite(unsigned char data)
{
TXREG=data;
while(TXIF==0);
TXIF=0;
}
void interrupt ISR(void)
{
if(RCIF==1)
{
RC0=1;
n=RCREG;
if(n=='a'){
serialwrite(temp1);
serialwrite(temp2);
serialwrite(temp3);
}
RCIF=0;
}
}
void main()
{
TXSTA=0X20;
RCSTA=0X90;
SPBRG=129;
BRGH=1;
TRISC7=1;
TRISC6=0;
TRISC0=0;
TRISA=0XFF;
TRISD=0X00;
TRISB=0X00;
ADCON0=0X01;
ADCON1=0X0C;
ADCON2=0X2D;
PEIE=1;
GIE=1;
RCIE=1;
serialwrite('a');
while(1)
{
delay();
ADCON0=0X01;
GODONE=1;
while(GODONE==1);
PORTD=ADRESH;
temp1=ADRESH;
delay();
ADCON0=0X05;
GODONE=1;
while(GODONE==1);
temp2=ADRESH;
delay();
ADCON0=0X09;
GODONE=1;
while(GODONE==1);
temp3=ADRESH;
}
}
ADC working checked PORTD pins ....