monitoring the sclk of the spi

05 Nov 2011

Dear all,

I am a little bit puzzled. I just started working with the mbed and in the end the mbed should controll via the SPI a DDS (Direct Digital Synthesizer).

I wanted to look at the SCLK out signal (set to 1 MHz, i used this http://mbed.org/handbook/SPI code) at Pin 7 with an oscilloscope. Accordingly i connected the ground pin and pin 7. What I see when setting the the oscilloscope to 1 us/Div and .5 V/ Div is a CONSTANT signal at 2 V.

Expected for me is a rectangular signal with 3 V peak.

Are there any ideas what is going wrong?

05 Nov 2011

a hambi,

I am taking a few guesses. If you have not connected your SPI pins to a SPI slave device and only using your scope to look for the SCLK then what you are seeing is probably correct. The mbed does not send clock pulses continuously it only sends SCLK pulses when reading or writing data to a slave. If you are only using the program snippet in the link it would complete in less than 1mS, so you need to setup your scope to trigger on a rising edge or falling edge and put your prog in a loop to have a good chance of seeing the SCLK or use a storage scope. You also need to connect a slave device.

Dave.

05 Nov 2011

Hi Dave,

thanks a lot! I didn't know that it only sends the clock signal when writing or reading. Then I will write a code that would continuously write to a slave device and try it out tomorrow or monday : )

06 Nov 2011

: { I tried it and it still shows only the 2V signal. Maybe I do a mistake in the code? I use now:

  1. include "mbed.h"
  2. include "AD9954.h" see below for what that is

Serial pc(USBTX, USBRX); DigitalOut myled(LED1); AD9954 myDevice(p5, p6, p7, p8, p9);

int main() {

while(1) { myDevice.CFR2_write(0x00000008); myDevice.FTW0_write(0x80000000);

uint32_t ftwo; ftwo = myDevice.ftwo_read();

uint32_t cfcr1; cfcr1 = myDevice.cfcr1_read(); } }

where I use Remy's code from this thread http://mbed.org/forum/helloworld/topic/1664/?page=1#comment-8346 to read and write.

I thought that this would create an endless write loop.

06 Nov 2011

problem misteriously resolved : )) thanks : )