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

Has anybody had success with the LTC1865 ADC

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



Joined: 19 Nov 2003
Posts: 30

View user's profile Send private message

Has anybody had success with the LTC1865 ADC
PostPosted: Thu Sep 14, 2006 8:48 am     Reply with quote

Hi,
When running the code below, I don't seem to get two inependent chan's.
Any ideas as to what could be wrong, or if anyone has working code I could try would be great.
Many thanks
Les

//------System------

#include <18F2620>
#fuses INTRC_IO,NOWDT,NOPROTECT,NOMCLR
#use delay(clock=8000000)

//------serial streams------

#use rs232(baud=57600, xmit=PIN_C6, rcv=PIN_C7, errors, stream=monitor)

//------Defines------

#define ADC_CLK PIN_C1
#define ADC_DOUT PIN_C2
#define ADC_DIN PIN_C0
#define ADC_CONV PIN_A6

//------Prototypes------

void init(void);
int16 adcValue(int8);

//*****************************************************************************

void init(void)
{
output_low(ADC_DIN);
output_high(ADC_CLK);
output_low(ADC_CONV);
}

//*****************************************************************************

int16 adcValue(int8 muxChan)
{
int8 numCks;
int16 data=0;

for(numCks=1;numCks<=16;++numCks){

output_high(ADC_CONV); //start conversion.
delay_us(10);
output_low(ADC_CONV); //enable capture.
delay_us(2);
output_low(ADC_CLK);
delay_us(2);
switch(numCks){ //set the data in for the mux chan.
case 1 : output_high(ADC_DIN);
break;
case 2 : if(muxChan==0)output_low(ADC_DIN);
else output_high(ADC_DIN);
break;
}
delay_us(2);
output_high(ADC_CLK); //din and dout sync on lo to hi.
delay_us(2);
shift_left(&data,2,input(ADC_DOUT)); //shift in data
delay_us(2);
}
return(data);
}

//*****************************************************************************

void main(void){
int8 x;
delay_ms(1000);
init();
while(true){
fprintf(monitor,"%lu %lu\r\n",adcValue(0),adcValue(1));
delay_ms(1000);
}
}
//-----------------------------------------------------------------------------
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