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.

[SOLVED] PIC16F877 Basic ADC Problem using C language, MPLAB and ISIS programs

Status
Not open for further replies.

clarence501

Junior Member level 3
Joined
Jan 24, 2011
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Philippines
Activity points
1,463
Hi Guys, can someone help me solve the problem that i have with this program? I can't run the simulation with it and I wonder what's wrong with it.

#include<pic.h>
int tenbit = 0;
void initialize(void);
main()
{
TRISE = 0x4;
ADCON0 = 0xB9;
ADCON1 = 0x80;
}

void initialize(void)
{
ADGO = 1;
while(ADGO)
{}
tenbit = ((ADRESH*256)+ADRESL);
if (tenbit>358)
{
PORTD = 0x00;
}
else
{
PORTD = 0x20;
}
}

These are the links to the ISIS model that I made:
Image - TinyPic - Free Image Hosting, Photo Sharing & Video Hosting

https://obrazki.elektroda.pl/89_1297387134.jpg


I used RE2 as the analog input and my output is RD5.

 

Hi clarence501,

You have forgotten to call the function "initialize()" inside main().

Thanks,
 

This is my new program but still not working. TRISE has 3 ports. How do I configure it if I use RE2?

#include<pic.h>
int x = 0;
int tenbit = 0;
void initialize(void)

{
TRISE = 0x07; //
ADCON0 = 0xB9;
ADCON1 = 0x80;

}
main()

{
initialize();
while(1);
{
ADGO = 1;
while(ADGO)
{}
tenbit = ((ADRESH*256)+ADRESL);
if (tenbit>358)
{
PORTD = 0x00;
}
else
{
PORTD = 0x20;
}
}
}
 

hi

and you did not configured PORTD as output port

ml
 

guys, i have already solved this problem on my own. hehehe. thanks for the tips though. the only problem was because of the semicolon after "while(1)"
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top