Rich (BB code):
# include<built_in.h>
int value;
void main()
{
ANSEL=0x01;
TRISB=0;
TRISA=0xFF;
ADCON0=0xC0;
ADCON1=0;
ADCON0|=(1<<0);
do
{
ADCON0|=(1<<1);
while(ADCON0/1);
if(value>500)
PORTB=1;
else
PORTB=0;
}
while(1);
}
# include<built_in.h>
int value;
void main()
{
ANSEL=0x01;
TRISB=0;
TRISA=0xFF;
ADCON0=0xC0;
ADCON1=0;
ADCON0|=(1<<0);
do
{
ADCON0|=(1<<1);
while(ADCON0/1);
if(value>500)
PORTB=1;
else
PORTB=0;
}
while(1);
}
I am using MicroC Pro for making programs. Earlier I made 2-3 programs using only built_in.h but now its giving error of ANSEL register.You need to include the required header (s) for your compiler. What compiler are you using?
Yes it helps in taking analog input for built in ADC.Is there an ANSEL register on this mystery chip you are trying to program?
Thanks for your help and patience. But I think I found solution so I wont bother you for a little whileWhy, yes, I did forget...
I am not familiar with MikroC, so I may not be too much help on that front, but I'm pretty sure that the compiler includes the required files automatically...
What PIC are you using?
Perhaps you could post your solution, I am curious, and I'm sure it could help others...Thanks for your help and patience. But I think I found solution so I wont bother you for a little while
i already posted solution in 8th comment
This isn't a solution to your problem, this is a work around. What if you had to use that device in a professional product? Would you tell your boss that you have to buy a new PIC just because you were getting an error?Anyway I changed to pic16f887 and it worked fine.
I see.. I thought he was just asking and i never gave a thought that he might be giving a hint to check whether this pic supports Ansel register. Great whaatsthatsmell..Okay, whatsthatsmell wins the prize! the 16F877 doesn't have an ANSEL register! The ADC pin functions are selected using ADCON1....
Very True.. But I thought that every pic might have ansel register. Microchip should work on standardizing its productThis isn't a solution to your problem, this is a work around. What if you had to use that device in a professional product? Would you tell your boss that you have to buy a new PIC just because you were getting an error?
Anyway, I believe I've already found the proper solution as in my previous post...
For future reference, you cannot hope to program a microcontroller without first reading the datasheet.
That's not possible. Considering there are so many PIC produced and spaced out in so many years. Some of the PIC dont even have an ADC or UART. Some have banked switched registers and some dont. Some like the 16F84 are being phased out and replaced by 16F628 etc etc.Very True.. But I thought that every pic might have ansel register. Microchip should work on standardizing its product
They have, but it's not like they can go back and change some very old and near obsolete devices (such as the one you are using) once released.Very True.. But I thought that every pic might have ansel register. Microchip should work on standardizing its product