This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADS8320 interfacing atmega1281

Other Parts Discussed in Thread: ADS8320

Hi there,

Im getting stucked lately using an ads8320 connected to my microcontroller, an Atmega1281. The problem is that I have no signal in the DOUT pin of the converter and I cant figure why.

This is the image from the oscilloscope:

I have checked carefully the connections and everything seems right.

My code is the following:

//Variables globales
unsigned char data=0x01,data1=0x3D,aux2,adc1,adc2,adc3,todouno=0xFF;
//int adc=0x00;

//Mis funciones
void SPI_MasterInit(void);
void writetoreg(unsigned char);
unsigned char readdata(unsigned char data);
void resetADC(unsigned char cDataH);
void _delay_ms (double __ms);
unsigned char readfromreg(unsigned char data8);

int main(void)
{
    
    //Configurar puertos e inicializar
        SPI_MasterInit();
        sei();
        
    while(1)
    {
        
    
        
        //read 16 bits data
        PORTB = (0<<PB0)|(1<<PB4)|(1<<PB5);//cs low
        adc1=readdata(todouno);
        adc2=readdata(todouno);
        adc3=readdata(todouno);
        PORTB = (1<<PB0)|(1<<PB4)|(1<<PB5);//cs high
    }
}

void SPI_MasterInit(void)
{
    /* Set MOSI,SS and SCK output, all others input */
    DDRB = (1<<DDB1)|(1<<DDB2)|(1<<DDB0)|(1<<DDB4)|(1<<DDB5);
    PORTB = (1<<PB0)|(1<<PB4)|(1<<PB2);//fsync disp1
    /* Enable SPI, Master, set clock rate fck/16 , MSB first*/
    SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0)|(0<<DORD)|(1<<CPOL)|(0<<CPHA);
}

unsigned char readdata(unsigned char data)
{
    //PORTB = (0<<PB0)|(1<<PB4)|(1<<PB5);//cs low
    unsigned char adc;
    SPDR = data;
    adc = SPSR;
    // Start transmission
    while(!(SPSR & (1<<SPIF)));
    adc = SPSR;
    //PORTB = (1<<PB0)|(1<<PB4)|(1<<PB5);// cs high
    return adc;
}

Any help or tip you could give would help me a lot. Thanks

Regards, Daniel.