SPI Slave not working on STM32 F429ZI

05 Oct 2016

I can't get the SPI slave to do anything at all on the STM32F429ZI board. All that happens in that LED2 blinks after reset, I don't get any code execution in main(), meaning something isn't working in the SPISlave object creation.

Any idea on how to implement SPI Slave?

SPI Slave on the STM32 F429ZI

#include "mbed.h"

DigitalOut myled(LED1);

SPISlave device(PB_5, PB_4, PB_3, PA_4); // mosi, miso, sclk, ssel

int main()
{
    int i;
    for (i=0; i<20; i=i+1) {
        myled = 1; // LED is ON
        wait(0.2); // 200 ms
        myled = 0; // LED is OFF
        wait(1.0); // 1 sec
    }

    device.reply(0x00);              // Prime SPI with first reply
    while(1) {
        if(device.receive()) {
            int v = device.read();   // Read byte from master
            v = (v + 1) % 0x100;     // Add one to it, modulo 256
            device.reply(v);         // Make this the next reply
        }
    }
}