|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
external ADC, SPI |
Posted: Thu Jul 05, 2007 8:04 am |
|
|
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
|
|
Posted: Thu Jul 05, 2007 8:29 am |
|
|
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 |
|
|
|
|
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
|