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.

PIC 16f877A interfacing with ADC

Status
Not open for further replies.

john86

Newbie level 4
Joined
Apr 3, 2012
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,340
Dear all! :)
I need a help on C Code for PIC 16f877A interfacing with ADC (AD7715-5)
My analogue input is 0-5 volts. First of all I wanna show something from ADC in PORTD that is connected to 4 seven segments.
I used an ADC because I need more accuracy and the 10 bit ADC of PIC16f877A is not enough for me.
please help me to do it. :razz:
Regards,
 

Start of by writing down your requirements / user stories. Then search EDA and the WWW were you will find many posts (and) code for SPI communications with the selected A2D chip.
If you read the spec of the AD7715 you will find SPI example C code
 
  • Like
Reactions: john86

    john86

    Points: 2
    Helpful Answer Positive Rating
Start of by writing down your requirements / user stories. Then search EDA and the WWW were you will find many posts (and) code for SPI communications with the selected A2D chip.
If you read the spec of the AD7715 you will find SPI example C code


Thanks for your comment but I read AD7715 datasheet and there was C code for another micro controllers not for PIC. therefore it was confusing for me!
I searched every where and there was any "C Code" or even "assembly code" for interfacing the PIC (any kind of it) with AD7715. :-(
 

Instead of going straight into that, first, tell us, did you previously use SPI? If you're not comfortable with it, you should practice using SPI first. Then, it'll be easier for you.
Then, go through the datasheet and the specific sequence required. If you can make use of the SPI module, you should be able to do it yourself.

For reference, you may take a look here: https://www.ccsinfo.com/forum/viewtopic.php?p=65392

You haven't mentioned which compiler you use.

Hope this helps.
Tahmid.
 
  • Like
Reactions: john86

    john86

    Points: 2
    Helpful Answer Positive Rating
Instead of going straight into that, first, tell us, did you previously use SPI? If you're not comfortable with it, you should practice using SPI first. Then, it'll be easier for you.
Then, go through the datasheet and the specific sequence required. If you can make use of the SPI module, you should be able to do it yourself.

For reference, you may take a look here: https://www.ccsinfo.com/forum/viewtopic.php?p=65392

You haven't mentioned which compiler you use.

Hope this helps.
Tahmid.



Dear Tahmid, Thanks for your comment
Actually I didn't use SPI before!! :) do you have any simple projects for me to accustom with SPI first?

I use MikroC. I'm wondering that if I use a different compiler (for example HI-Tech) it will result a different C code??!! or somthing like that?

meanwhile, I'm not sure about my wiring between AD7715 and PIC!! if I was, It would be an improvment for me. I read the AD7715's datasheet, but I'm not sure.
so I added an Image for you to help me to reform or improve it.

hey, I thought it's C code will be simpler but apparently its not!!my code is;


void main() {
CMCON |= 7; // Disable Comparators
TRISD=0x00; // Set PORTD direction to be output
TRISC=0xff;
TRISB=0x00;
PORTB=0;

SSPCON=0b00000100;
SSPCON2=0;
SSPSTAT=0;
SSPCON.SSPEN=1;

while(1) {
while (PIR1.SSPIF==0);
PORTD=SSPBUF;
}
}



anyway, thanks for the link. BUT its a C code for CCS Compiler and its own built-in functions. I work with MikroC.I'm trying to reform that for my usage.I hope it works for me too! :)
I'm looking forward for your answer
regards,


 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top