Re: Help needed with spi interfacing to mcp3208 and ads7871
Scott Henion <[email protected]>
| Newsgroups | gmane.comp.hardware.rabbit-semiconductor |
|---|---|
| Message-ID | <[email protected]> |
On 5/1/2013 2:51 PM, santogiuseppe wrote:
> Hello,
> so far i succeeded to interface the minicore 6750 (and the rcm4000) with max4820, max31865 (an RTD-to-Digital Converter) and a touchscreen display but i have serious problems with ads7871 and mcp3208
> I dont know what's the problem, the spi's signals (cs, miso, mosi and the serial clock) are connected to a logic analyzer,
> and the communication (cs, clock and the mosi from the minicore) seems ok, but i'm not receiving the chips replies!!(and i'm going MAD!!)
> I use the same spi with other chips, and i changed the cs only to connect these chips
> 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
------------------------------------------