SPI communication

Forum for problems or queries regarding Flowcode Comms Components. Eg LIN, I2C, SPI, RS232, CAN, IrDA etc

Moderators: Benj, Mods

Post Reply
Bjorn
Flowcode V4 User
Posts: 2
Joined: Mon Sep 14, 2009 9:17 am
Contact:

SPI communication

Post 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
Attachments
SPI_forum.fcf
Test programme
(21.33 KiB) Downloaded 441 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI communication

Post 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.

Bjorn
Flowcode V4 User
Posts: 2
Joined: Mon Sep 14, 2009 9:17 am
Contact:

Re: SPI communication

Post 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

Post Reply