Problems with SPI and ADS8320

Erio Magnoni <magnonie-ur28x6/[email protected]>
Newsgroups gmane.comp.hardware.microcontrollers.tini
Message-ID <[email protected]>
Hi Jeremy! Hi everyone!
I tried seting the spi delay to 1 as you told me and now I see the correct 
behaviour. The problem now is that I can read only 10 bits of the 16 the ADC 
returns.
As I see from the oscilloscope after 10 bits chip select signal goes high and 
low causing the ADS8320 to restart bitstream transmission. What can I do to 
read all of the 16 bits? 
I tried to change the array length but this causes an arrayindexoutofbounds 
exception...

Here is spi initialization:

spi = new SPI(1, true, true, false, false, false, false, true);

Here is the source code that performs conversion:

...

void convertAtoD(double samples) {

	System.out.println("Performing conversion...");

        byte[] spidata = new byte[4];

	for(int i=0; i<4; i++)
	{
		spidata[i] = (byte) 0x00;
	}

        spi.xmit(spidata, 0, spidata.length);

	System.out.println();
	System.out.println("Array dimension: " + spidata.length);

        for(int i=0; i<4; i++)
        {
	        System.out.print("Bitstream: ");
		printBinary(spidata[i]);
	}
          
	System.out.println();
	System.out.println("Completed.");

}


private static void printBinary(byte b) { 
        for (int val = 7; val >= 0; val--) 
        { 
                System.out.print((b >> val) & 1); 
        } 
 
        System.out.println(); 
} 

...

Thanks a lot for the support!

Best regards,
Erio Magnoni.

SUPSI-DTI, Manno, Switzerland

-------------------------------------------------
This mail sent through IMP: https://mail.die.supsi.ch
_______________________________________________
TINI mailing list
TINI-6tN4nzCoH/[email protected]
To UNSUBSCRIBE, edit your profile, or see list archives:
http://lists.dalsemi.com/mailman/listinfo/tini
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.