Searching \ for '[PIC]: SPI code for TLC2543 ADC' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/ios.htm?key=adc
Search entire site for: 'SPI code for TLC2543 ADC'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: SPI code for TLC2543 ADC'
2001\10\31@125811 by David Huisman

flavicon
face
I am wanting to interface PIC to TLC2543 ADC. I have obtained some
bit-bashed SPI code from a web site and copied a snippett below.

The author states that the code has been tested and runs fine but I have
some questions...

The TLC2543 ADC serial stream is MSB first. The command word (first 8 bits
sent) are structured
such that the 4 MS bits are channel and the 4 LS bits are control bits (in
this case the control bits are "0000").

The questions I have relating to this code (I have emailed author with no
response) are..

1) Why would "i" need to be signed, I see no reason why it cannot be
unsigned int

2) Should not the channel variable be shifted left 12 places to be in
correct position for ADC

3) To send MS bit first, should not the shift operator in "ad_data_in = ..."
line be to left

4) Have I misunderstood the TLS2543 data sheet and it actually receives LS
bit first but sends MS bit first ? There is a MS first/LS first programmable
option but only for data out.

Thanks

Regards

David Huisman

**** NOTE ad_data_in = data into ADC, ad_data_out = data output from ADC
****

       signed char i;
       unsigned int data = 0x0;
       unsigned int ch_config;
       ch_config = channel<<8;

       ad_cs = 0;
       for(i=11; i>=0; i--)
       {
               ad_data_in = ((ch_config>>i) & 0x01);
               data <<= 1;                                                                                                                     data |= ad_data_out;
               io_clk = 1;
               io_clk = 0;                                                                                                             }
       ad_cs = 1;

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...