Page 1 of 1

SPI communication

Posted: Mon Sep 14, 2009 11:11 am
by Bjorn
Hi,

I use a MCU (18f4685) and ADC (AD7738). I've connected SDO (MCU) to DIN (ADC), SDI (MCU) to DOUT (ADC), SCK (MCU) to SCK (ADC) and connected the #CS (ADC) to the ground. In my attached flowcode programme first I init the SPI hardware and reset the ADC by sending 0,1,1,1 over SPI. After that I setup the various configuration registers. Then i start a while loop thats gives the ADC a command for single conversion, followed by a delay and a command to read the data register for channel 0. I send back the result over rs232.

When i measure with a oscilloscope, I see the four SPI clock pulse trains (4 x 8 pulses) and the pulse train from the MCU's SDO pin (bytes 72, 0, 0, 0). When i measure the MCU's sdi pin (ADC's SDO) I see no activity. We did some experiments with SPI speed and polarity but the result is always the same, nothing.

Can somebody please look at my programme and give some suggestions.

Thanks in advance,

Bjorn Stevens

Re: SPI communication

Posted: Mon Sep 14, 2009 12:58 pm
by Benj
Hello

Attaching the CS to ground may be your problem. In some systems the CS has to be toggled to allow the SPI device to behaive correctly. This is the case with normal SPI SD/MMC cards.

Also might be worth checking that the SPI conmponent properties are correct eg the speed, the polartiy of the clock etc.

If your still stuck then let me know and I will look into it further for you.

Re: SPI communication

Posted: Mon Sep 14, 2009 1:14 pm
by Bjorn
Hi Benj,

We used to toggle the cs line with a digital I/O pin on the MCU. But that's also not working. So we decided, according to page 20 figure 5a, to permanently pull down the cs line to ground. According to figure 6 on page 20 the clock polarity should be idle high. We're not sure about the other parameters.

Thanks for your help, maybe you've got other suggestions for me.

Regards, Bjorn