SPI API

28 Oct 2010 . Edited: 28 Oct 2010

I am using SPI Interface mbed pins p5/p6/p7. I configure the SPI interface setting are 1MHz, 8-bit, Mode 0

    spi.format(8,0);
    spi.frequency(1000000);

When I issue  int dataread = spi.write (0x01), I noticed that the SCK only active for  the duration of the 8 clock cycles to send out that 8-bit data. I am hoping that as long as I have chip select activated, I want the clock to remain toggling. 

How do I keep the clock remain toggling as long as the chip select is high? Is the a limitation of the spi.write API?

28 Oct 2010

As far as I know, that's the way it's supposed to work. Otherwise, the device would read zeroes the whole time (assuming the data line is low when no data is sent).

28 Oct 2010

The original post above Igor's look's very different in my mailbox, have you editted it?

When using SPI to read/write flash or eeproms it's normal to send "don't care" bytes after commands/addresses to "keep the clock going". For example, in my read code I use a DMA channel to block read a page from flash. However, I have to use a second DMA channel to send out "don't care" bytes just to keep the sclk going for the number of page bytes I want to read.

29 Oct 2010

Thanks Andy !!! 

I got it to work by sending zeroes to the SPI MOSI line.

int keepclocking = spi.write (0x00);  // this will keep the MOSI line  low and data can be clock out onto the MISO line.

I edited my original post to make my question simpler.