PIC 16F877 Proramming using mikro c

Status
Not open for further replies.

rkt80

Newbie level 3
Joined
Sep 15, 2011
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Navi Mumbai (New Mumbai), India, India
Activity points
1,304
Hey, i am student and doing my project on pic 16f877. I am comparing one ADC input to one reference voltage. Based on condition i.e (ADC pin>reference voltage)or(ADC pin<reference voltage) LCD should display low or high only. I don’t know its programming part. and voltage coming to ADC pine is (0-5v).
i am using mikro c for its programming . Please provide me program for it, or any other help.
Thanks
 

Is it 16F877A or 16F877?
There's many examples in mikroC.
 

it's 16F877
Just see the circuits and the example programs below.
**broken link removed**
**broken link removed**

But you won't be able to compile the example program there because it has two registers ANSEL and ANSELH that are not used in 16F877.

For 16F877 the registers used to control the analog inputs are adcon1, adcon0, adresh and adresl. So delete ANSEL, ANSELH in example programs and then set the adcon1, adcon0, adresh and adresl according to your requirements.

Also there's an example in your pc somewhere like here.
C:\Program Files (x86)\Mikroelektronika\mikroC\Examples\EasyPic5\P16F877A\ADC_on_LCD

And asking you whether the microcontroller is 16f877 or 16f877a was a mistake. It doesn't matter for ADC I think.
These are examples only. Use them in your program.
You can get the reference voltage from a adc pin and then check the new value against the reference voltage using if conditions. When the condition is met display high or low.

if(oldValue > newValue)
{
//display "low"
}
if(newvalue > oldValue)
{
//display "high"
}
 
Last edited:

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…