Probem Using 10-Bit Data Acquisition System ADC LTC1090

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello friends, I was searching in google like a crazy but I can not find nothing about the ADC LTC1090 and AVR, I only found threads about it in German and not have much information (I have read them all with google translate).

Have you ever worked with this ADC?

Im using ATMEGA644PA, Im programing in C using IAR EWAVR, the LTC1090 accept SPI interface.

I just want to know if you have any source code example about this IC, I know how to program anothers IC's, like MCP4811 and were supposed to be similar, though not achieving the conversion to make it work.

I appreciate any advice and help.

Thanks in advance

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's something for an LTC1867... might be similar

//-------------------------------
char readspi(void){
//return char from spi
char cnt,stat;

  cnt=0;
  do{
    stat=SPSR;
    cnt++;
    if(cnt==255){
      cprintf("spi rcv timeout ");
      break;
    }
  }while((stat & 0x80)==0);  //keep checking until done bit
  return(SPDR); //clears done flag
}

//--------------------------
void spiout8(char c){
//send c out spi
char cnt,stat;

  SPDR=c; //send data
  cnt=0;
  do{
    stat=SPSR;
    cnt++;    
    if(cnt==255){
      cprintf("spi xmt timeout! ");
      break;
    }
  }while((stat & 0x80)==0);
}

//--------------LTC1867 stuff-------------------
#define CSLO()  PORTB &= ~0x01
#define CSHI()  PORTB |=  0x01

//command byte bit mask definitions (7 bits)      0: 1:
#define SD  0x40 //single/differential            40 40
#define OS  0x20 //odd/sign                       00 20
#define S1  0x10 //                               00 00
#define S0  0x08 //                               00 01
#define COM 0x04 //com=1 means ch7 is minus in    04    
#define UNI 0x02 //unipolar                       02
#define SLP 0x01 //sleep                          00
//-------------------------------------------cmd: 46 8c after shl

//----------------------------0 1 2 3 4 5 6 7 channum
//__flash char chancode[8] = {0,2,4,6,1,3,5,7}; //COM is grounded, so only 7 channels available
__flash char chancode[8] = {0,4,1,5,2,6,3,7}; //COM is grounded, so only 7 channels available
unsigned char cmd;
//-------------------------------------------
unsigned int readadchan16(char channum){
//read ch n of 16 bit a/d LTC1867   0-0xffff
//this routine reads a/d twics, because channel might have changed since last read
unsigned int dh;
unsigned char dl;
unsigned char chncod; //3 bits
unsigned int tmp;

  chncod=chancode[channum]; //look up real chan code
  cmd=0; //start building cmd from 0
  cmd = ((SD | (chncod << 3)) | COM) | UNI; //form cmd byte 7 bits 0x46 for ch 0

  CSHI();            //start conversion
  delnus(5);         //time for conversion (200K samps per sec)
  CSLO();            //chip select to send cmd
  spiout8(cmd << 1); //send cmd byte flush left (sent most sig bit first)
  dh=readspi();      //read hi byte
  spiout8(00);       //send dummy to get lo byte
  dl=readspi();      //read lo byte
	
  CSHI();            //start conversion
  delnus(5);         //time for conversion
  CSLO();            //chip select to read data
  spiout8(cmd << 1); //send cmd again to get hi byte
  dh=readspi();      //read hi byte
  spiout8(00);       //send dummy to get lo byte
  dl=readspi();      //read lo byte

  tmp=((unsigned int)dh << 8) | dl; //form result
  return tmp;
}

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok thank you, I will try sending "cmd" twice.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

IF I POST SOME IMAGES, CAN SOMEONE HELP ME TO UNDERSTANDING HOW THAT WORKS?