9 years, 8 months ago.

SPI pin not reconized

Hi,

I'm tring to code a spi bus for my stm32f7 discovery.

I have this:

#include "mbed.h"
SPI spi(p5, p6, p7);
DigitalOut cs(p8);

but when I compile it says: Identifier "p5" is undefined "SPI spi(p5, p6, p7);" and this for all of it. I tried to recreate a programme but still have the problem. any help ? thx NI3

1 Answer

9 years, 8 months ago.

Bonjour Kevin. Please review the target board webpage:

https://developer.mbed.org/platforms/ST-Discovery-F746NG/

and note the details on how to use the port pins. For this board, you must use only the BLUE / WHITE or GREEN / WHITE labels. The identifiers in your code are for a different target board (not the STM32F7).

try the following instead:

//
// use only port pins from the target board diagram
//
// wire up your external hardware using the applied port pin labels
//
#include "mbed.h"
SPI spi(d11, d12, d13); // mosi, miso, sclk
DigitalOut cs(d10);  
//

Update - Kevin, also be sure to UPDATE your mbed library in your project. This is important else your imported project / examples will be using older library code and may not properly support your target board. To UPDATE, select the mbed label in your project -> select the UPDATE button on the right side of your compiler screen.

Update #2 - Review the following notes which appear to be related:

https://developer.mbed.org/questions/6691/Compile-Error-number-322/?sort=

Update #3 - Try the following:

Reference: https://developer.mbed.org/cookbook/SD-Card-File-System

1) Import this program into your workspace:

https://developer.mbed.org/compiler/#import:/users/mbed_official/code/SDFileSystem_HelloWorld/

2) Select your target hardware board.

3) Update the mbed library for this workspace.

4) Change the main program to reflect the following:

#include "mbed.h"
#include "SDFileSystem.h"
 
//SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
// SDFileSystem sd(p5, p6, p7, p12, "sd"); // MOSI, MISO, SCLK, SSEL
SDFileSystem sd(D11, D12, D13, D10, "sd"); // the pinout on the mbed Cool Components workshop board
 
int main() {
    printf("Hello World!\n");   
 
    mkdir("/sd/mydir", 0777);
    
    FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
    if(fp == NULL) {
        error("Could not open file for write\n");
    }
    fprintf(fp, "Hello fun SD Card World!");
    fclose(fp); 
 
    printf("Goodbye World!\n");
}

There is a mention that the SDFileSystem has been superceded but start with the above to be sure it can compile for you and then proceed to update any code that may be required for this task.

https://developer.mbed.org/users/mbed_official/code/SDFileSystem/

The following appears to be the latest version of the above (not confirmed):

https://developer.mbed.org/teams/mbed/code/SDFileSystem/

The above SPI definition compiles fine on my side but has not been tested with a live SD card. Give it a try and post your results.

Hi thanks for answering !

I put the modification and update. when compiling I have 8 L6218E error like this one:

Error: Undefined symbol mbed::FATFileSystem::open(const char*, int) (referred from SDFileSystem.cpp.DISCO_F746NG.o).

I'm using the SDFileSystem librarie

posted by KEVIN JOUAN 23 Feb 2016