0

I have set up a very simple spi master example, but looking at the logic analyser there is no spi clock line. So what have I done wrong in the configuration of the spi.

#include "mbed.h"
#include <stdio.h>

SPI spi(D4, D5, D3); // mosi, miso, sclk
DigitalOut cs(A2);

Serial pc(USBTX, USBRX); // tx, rx

int main() {
    cs = 1;
    spi.format(8,3);
    spi.frequency(1000000);

    // Select the spi by seting chip select low
    cs = 0;

    // Send some data
    spi.write(0xFA);

    // Send a dummy byte to receive the contents of the WHOAMI register
    int whoami = spi.write(0x00);
    pc.printf("WHOAMI register = 0x%X\n", whoami);

}
homeGrown
  • 375
  • 1
  • 8
  • 25
  • I would say that this SPI you are trying to use is not supported. It is funny how mbed knows which SPI to use when you init it with SPI class. Try pins D10, D11 and D12 (find out order for constructor) as this SPI is the *first* one. – unalignedmemoryaccess Jun 07 '17 at 11:06
  • @tilz0R Tried these too. Not clear exactly which pin is for slave select I am using D10 – homeGrown Jun 07 '17 at 11:52
  • Did the answer [here](https://developer.mbed.org/questions/78226/SPI-example-not-working-on-NUCLEO-F411RE/) help you? – Jan Jongboom Jun 09 '17 at 16:34

0 Answers0