CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

problem with ad7715 adc

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kansusid



Joined: 12 Jun 2006
Posts: 9
Location: INDIA

View user's profile Send private message

problem with ad7715 adc
PostPosted: Mon Jun 19, 2006 6:13 am     Reply with quote

well i am using an ad7715-3 with a pic16f877a ic the code used is similar to the one posted in the driver of ccs compiler
li'l abt ad7715
the code is


#include <16f877A.h>
#device 16f877*=16 ADC=8 //8 bit resolution
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT

#use delay(clock=6000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,stream=,bits=8)



#define ADC_CS PIN_C7
#define ADC_RESET PIN_C6
#define ADC_DRDY PIN_C2
#define ADC_DI PIN_C4
#define ADC_DO PIN_C5
#define ADC_CLK PIN_C3

void write_adc_byte(BYTE data);

void adc_init()
{
output_low(ADC_RESET);
output_high(ADC_CLK);
output_high(ADC_CS); //Set low to AD7715 chip select low pin
output_high(ADC_RESET); //Set high to AD7715 reset low pin
delay_ms(3000);

write_adc_byte( 0x12 ); //Communications Register
write_adc_byte( 0x74 ); //Setup Register info here
return;
}

void write_adc_byte(BYTE data) {
BYTE i;

output_low(ADC_CS);
for(i=1;i<=8;++i) {
output_low(ADC_CLK);
output_bit(ADC_DI, shift_left(&data,1,0));
output_high(ADC_CLK);
}
output_high(ADC_CS);
return;
}


long int read_adc_word() {
BYTE i;
long int data;

output_low(ADC_CS);
for(i=1;i<=16;++i) {
output_low(ADC_CLK);
output_high(ADC_CLK);
shift_left(&data,2,input(ADC_DO));
}
output_high(ADC_CS);
return data;
}

long int read_adc_value() {
long int value;

while ( input(ADC_DRDY) );
while ( !input(ADC_DRDY) );
while ( input(ADC_DRDY) );

write_adc_byte(0x3a);
value=read_adc_word();

return value;
}




void main()
{
long int val=0;
set_TRIS_C(0x24);
//set_TRIS_B(0x01);
//output_high(PIN_C1); ///SCLCK HIGH

adc_init();//writei(0x10); //write into comm. register to write into setup reg in next cycle
//delay_ms(1000); //1 sec delay
//writei(0x74); //self calibration
//printf("before while");
//write_adc_byte(0x1a);
val=read_adc_value();
printf("\nfirst data is %4x",val);
//while(input(PIN_B0));
//printf("\nfinished while");
//writei(0x38);//into comm
//read();

while(1)
{
val=read_adc_value();
printf("\n data is %4x",val);
printf("\nend");
delay_ms(1000); //delay of 1sec
}
printf("\nend");
}



the problem: i am getting almost the same values for 3.3V and gnd
and the values for some of the voltages say voltage across a resistor are not accurate but surprisingly consistent the high i have give is 3.3V for both DVdd and AVdd <both from same voltage source> i have used a 2.4576MHz oscillator everything is according to the circuit shown in ad7715 datasheet

so pl help in finding what is wrong!!
kansusid1
Guest







problem with ad7715 adc
PostPosted: Mon Jun 19, 2006 11:11 pm     Reply with quote

pl help me .pl do reply don't get baffled looking at the length my question major part of the question is the program which is quite similar to the driver present in the ccs compiler
I REALLY NEED HELP PLEASE HELP ME
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 20, 2006 10:53 am     Reply with quote

Quote:
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,stream=,bits=8)

#define ADC_CS PIN_C7
#define ADC_RESET PIN_C6
#define ADC_DRDY PIN_C2
#define ADC_DI PIN_C4
#define ADC_DO PIN_C5
#define ADC_CLK PIN_C3

You have the AD7715 pins connected to the same pins as the RS232
serial port. It won't work. Choose some different pins for the ADC_CS
and ADC_RESET signals.
kansusid



Joined: 12 Jun 2006
Posts: 9
Location: INDIA

View user's profile Send private message

PostPosted: Wed Jun 21, 2006 9:34 pm     Reply with quote

Thank you very much. It Works now!!!
_________________
kansusid
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group