--- In r..., Scott Henion wrote:
[cut]
> > Maybe it's the schematics...there is someone
who succeeded to
interface with the ads787x or mcp320x chips family and is so kind to
share the schematics?
> > Thanks in advance
>
> I have used the MCP3208. Here is the code:
>
> unsigned read_atod(int chan)
> {
> unsigned txbits,rxbits;
> txbits=0x01; // start bit
> outi(PEDR,srPEDR&=~PORTE_ADCS);
> SPIWrite(&txbits,1);
> txbits=0x80 | (chan<<4);
> SPIWrRd(&txbits,&rxbits,2);
> outi(PEDR,srPEDR|=PORTE_ADCS);
> return swapb(rxbits);
> }
>
> This was for Softools, outi() is similar to WrPortI(), it just sets
the
> CS line low/high. The function swapb() swaps the
high/low bytes as
they
> are received, high/low and I need low/high.
>
> You also need to consider if the SPI library is sending data MSB first
> or not. That is determined if SPI_NOREV is defined.
>
> --
> ------
> Scott G. Henion, Consultant
> Web site: http://SHDesigns.org
> ------
>
Thank you mister Scott!!
Although i dont think it's the protocol, and i dont think it's the
spi
configuration, because to try the spi code i use a loop where i can
interactively change the spi settings: msb/lsb , clock speed, spi mode
etc
I just tried your way to communicate with the chip (with dynamic c it's
slightly different but not much), that is to send a byte with the start
bit and next the byte that sets single/differential conversion and the
channel to sample and...doesnt work [:(]
My way (following the datasheet suggestion) is a bit different in the
bits sequence i send (i blank the leading 5 zeros, not the leading 7 as
in your method), but the gist of it is exactly the same, on the logic
analyzer i see that the bit sequence i send is correct, but there are
not replies from the chip...
I think the problem is that the communication with the chip doesn't
happen at all
The datasheet says "If the device was powered up with the CS pin low (as
in my case), it must be
brought high and back low to initiate communication."
Then - to reset the chip before using it - i send the sequence CS HI -
delay (few microseconds) - CS LOW - delay - CS HI
Do you use a similar sequence to reset the chip?
Thank you very much for the answer