SPIslave not working on NUCLEO-F746ZG

Hi,
I have NUCLEO-F103RB as the SPI master and NUCLEO-F746ZG as the SPI slave. Both boards have a isoSPI/isolated CAN arudino shield (DC2617A - LTC6820) and I want to use isoSPI between them, so I have connected an ethernet cable between the shields on each board.

In the master (F103RB) I configured the pins:

MOSI = PA_7
MISO = PA_6
SCLK = PA_5
CS = PB_6

And on the slave (F746ZG) the pins are:

MOSI = PA_7
MISO = PA_6
SCLK = PA_5
CS = PD_14

The code does not give out any error, it is a simple code where the master sends a signal and the slave responds with the same signal (the code can be seen below).

Looking at the logic analyzer, MOSI works as it should so the master is working fine. However, MISO is not responding. The logic analyzer is connected to the master’s SPI pins. The MISO channel never goes to 0x00 and never prints “hello” in serial monitor, so the main function doesn’t seem to run (output from the logic analyzer is also attached below).

I thought that maybe there’s something wrong with the jumper connections on the slave, but I get the same results when I change the jumper position on JP1 and JP2.

I feel like there’s something missing. What is wrong?

Master code:

#include "mbed.h"
#include <SPI.h>
#include "stdio.h"
SPI spi(PA_7, PA_6, PA_5); 
DigitalOut cs(PB_6);

int main()
{
    while(true) {
        cs = 1; 
        spi.format(8,0); 
        spi.frequency(1000000);
        cs = 0; 
        spi.write(0x69);
        cs = 1;
        wait_us(1000); 
    }
}

Slave code:

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

SPISlave spi(PA_7, PA_6, PA_5, PD_14); 
BufferedSerial pc(USBTX, USBRX); 

int main()
{
    spi.reply(0x00);              // Prime SPI with first reply
    pc.set_baud(115200); 
    pc.set_format(8,BufferedSerial::None,1); 
    while (1) {
        if (spi.receive()) {
            spi.reply(spi.read());         // Make this the next reply
            printf("hello");
        }
    }
}

Logic analyzer:

Thanks,
Miko

Hello,

In your last topic

you wrote

It is now working

So this code worked when the boards were connected directly, but didn’t work when you used shields?

BR, Jan

Yes exactly. I use different pins now because of the shield (only SPI1 is available), however it does not give out the “pinmap not found” error this time when switching back to the SP1-pins (probably because of the ethernet cable?). So I think the code is fine, but the problem could be with pins/jumpers and maybe that NUCLEO-F746ZG does not understand that it is the slave.

//Miko

Just for sure you can try to remove the on board JP6 that will probably disconnect the PA7 out of Ethernet interface.

BR, Jan

Slave is still not responding after removing JP6, MISO is 0xff. Logic analyzer looks the same as the picture in my post.

// Miko

Okay, I saw that I was using the wrong baud rate and now I get pinmap not found error again (as in my previous post). So the problem seems to be PA_7 pin (MISO) on the slave.

I think the problem will be PD_14 and not the PA_7. Because the PD_14 is not a part of any SPI interface, correct one is PA_4 or PA_15 for the SPI1 CS.
I understand you need it because of the shield usage.
Maybe for verification you can take down the shield from board’s header and connect it via wires to different pins.

BR, Jan

1 Like

I removed the shield and tried PA_15 instead of PD_14 with CS and it worked, so at least we know the code is working fine. However, in PinNames.h for NUCLEO-F746ZG, it says under Standardized button names (row 275):

    SPI_CS      = D10,

and D10 is defined:

    D10         = PD_14,

So PD_14 should work?

Edit: I found this: Nucleo 144pins ethernet spi conflict - | Mbed and I want to communicate SPI by using an ethnernet cable, so maybe I need to connect PB_5 to D11 instead of PA_7?

That is great!

Hmm I do not think that is the right place. From my point of view the error about the pinmap occurs because the pin PD_14 is not in this map, because it is not a part of any SPI interface.

BR, Jan

Ok, I manually configured D10 to be PA_15 on the shield, by removing the pin from the shield and connecting a cable between PA_5 on the F746ZG board with D10 on the shield.

So now I connected an ethnernet cable between the shields and connected a logic analyzer on the master again, but it still gives no response from the slave on MISO and the serial monitor is empty as well. However there’s no error anymore, so the problem seems to be elsewhere now.

Still very strange that it doesn’t show the prints, then it must not even run the main function.

// Miko

So place more debug point to your app with printf or with leds (LED1, LED2, LED3)

int main()
{
    spi.reply(0x00);              // Prime SPI with first reply
    pc.set_baud(115200); 
    pc.set_format(8,BufferedSerial::None,1); 

    printf("Slave is running\n");

    while (1) {
        if (spi.receive()) {
            printf("Received\n");
            spi.reply(spi.read());         // Make this the next reply
            printf("Send\n");
        }
    }
}

BR, Jan

I did this, but even the first print didn’t show :frowning: the main function is not running, even though the board is on and everything is uploaded.

// Miko

Just an update. Turns out, the shield is hardwired as a master and cannot be modified to be a slave. So I’m trying it with a different shield now, hopefully that’ll solve the issue!

Thank you for all your help, really appreciated it!

// Miko

1 Like