ipunished
Junior Member level 3
- Joined
- Mar 15, 2011
- Messages
- 31
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- United Kingdom
- Activity points
- 1,504
Hello,
Ive read the data sheet of PIC 16F877 and coded my microcontroller accordingly, but it does not appear to work. I am using sourceboost as my compliler.
Here is my code:
ive set the registers accordingly, and Ive connected pin RA3 to Vref and RA0 is my analog input.
no matter what I do, the output value does not change and the adresl returned value is always 0.
Can anyone help me out here? Thank you
Ive read the data sheet of PIC 16F877 and coded my microcontroller accordingly, but it does not appear to work. I am using sourceboost as my compliler.
Here is my code:
Code:
#include <system.h>
unsigned char adcconv(void);
unsigned char inbyte;
void config(void);
void main(void)
{
config();
do{
portb=adcconv();
}while(1);
}
unsigned char adcconv(void)
{
adcon0.GO=1;
do{
}while(adcon0.GO==1);
return(adresl);
}
void config(void)
{
status |=0x20;
adcon0=0x0c1;
adcon1=0x01;
trisa=0xff;
trisb=0x00;
status &=0xdf;
}
ive set the registers accordingly, and Ive connected pin RA3 to Vref and RA0 is my analog input.
no matter what I do, the output value does not change and the adresl returned value is always 0.
Can anyone help me out here? Thank you