CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

external ADC, SPI

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








external ADC, SPI
PostPosted: Thu Jul 05, 2007 8:04 am     Reply with quote

Hi,
I have the PIC18F2480 and want to use an external AD-Converter, the AD7790.
In my Pic programm I wrote this:


void(main)
{
setup_spi(spi_master | spi_ss_disabled | spi_l_to_h | spi_clk_div_16 );

while (TRUE)
{

delay_ms(20);


s = spi_data_is_in();
fprintf(debug,"%Lu;", s);

spgref = output_high(PIN_B1);
fprintf(debug, "%f;", spgref);

faktor = spi_read();
fprintf(debug, "%f;\n", faktor);

}

}


Now I have the problem that I always get the same result in spi_read().
Where is the false??

Thanks.

TOM
Ttelmah
Guest







PostPosted: Thu Jul 05, 2007 8:29 am     Reply with quote

A lot of problems.
First look at the manual for 'SPI_DATA_IS_IN'. Now you are the master device, and clock all transactions. How can data arrive?.
Then look at the manual for the 'output_high' instruction. What does it return?. Does reading this make any sense?.
Then look at the data sheet for the AD790. What does it say you must do to read from it?. Page 10. First line about the communications register. Can you 'read' from the device, without first writing?.
What has to happen to the chips /CS line?. If you don't use this line, what do you have to do?.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group