ljb
Joined: 19 Nov 2003 Posts: 30
|
Has anybody had success with the LTC1865 ADC |
Posted: Thu Sep 14, 2006 8:48 am |
|
|
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);
}
}
//----------------------------------------------------------------------------- |
|