8 years, 8 months ago.

Pin map error

Hi !

I'm trying to get a sd card working for my project. But I have problem with the pinmap for the SDFileSystem:

SDFileSystem sd(PD_2, PC_8, PC_12, PC_11, "sd");

when I put it like this it is ok no error but the board send to the com port : pinmap not found for peripheral

and if I take of the underscore ( _ ) like in the datasheet (http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00190424.pdf ) it give me error when compiling

include the mbed library with this snippet

#include "mbed.h"
#include "TS_DISCO_F746NG.h"
#include "LCD_DISCO_F746NG.h"
#include "stm32746g_discovery_sd.h"
#include "SDFileSystem.h"
#include <string>

//def ecran et tactile
LCD_DISCO_F746NG lcd;
TS_DISCO_F746NG ts;

//def liaison serie
Serial pc(USBTX, USBRX); // tx, rx

//bus spi capteur
SPI spi(D7, D8, D13); // mosi, miso, sclk
DigitalOut cs_cap(D9);

//def carte sd
SDFileSystem sd(PD_2, PC_8, PC_12, PC_11, "sd");

//def variable
int LIGNE = 0;
int PTR = 0;
int ETAT = 0;
int whoami = 0;
int show = 0;
char buffer[128];
uint8_t status;
int i=0;
TS_StateTypeDef TS_State;

char* text[30];
char* init[100] = {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30",
                   "31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60",
                   "61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","87","88","89","90",
                   "91","92","93","94","95","96","97","98","99","100"
                  };

void PRINT(char *ptr)
{
    init[ETAT] = ptr;
    ETAT++;
    while(PTR != ETAT) {
        lcd.ClearStringLine(LIGNE);
        lcd.DisplayStringAtLine(LIGNE,(uint8_t *) init[PTR]);
        if(show == 0) {
            pc.printf((const char *) init[PTR]);
        }
        LIGNE++;
        PTR++;

        //wait(0.01);

        if(LIGNE >= 22) {
            show = 1;
            PTR++;
            PTR = PTR - LIGNE;
            LIGNE=0;
        }
    }
    pc.printf("\r\n");
    show = 0;
}

void Pourcent(float tmp)
{
    while(i <= 100) {
        sprintf((char*)text, "VERIFICATION: %d%%", i);
        pc.printf((const char *) "VERIFICATION: %d%%\r", i);
        lcd.DisplayStringAtLine(LIGNE,(uint8_t *) &text);
        wait(tmp);
        i++;
    }
    init[ETAT] = (char*) text;
    ETAT++;
    LIGNE++;
    PTR++;
    i=0;
}

void TouchScreen_Init(void)
{

    status = ts.Init(lcd.GetXSize(), lcd.GetYSize());
    Pourcent(0.01);
    if (status != TS_OK) {
        PRINT((char *)"");
        PRINT((char *)"**********TOUCHSCREEN PAS OK************");
    } else {
        PRINT((char *)"");
        PRINT((char *)"************TOUCHSCREEN OK**************");
    }
}

void SD(void)
{
    status = BSP_SD_Init();
    Pourcent(0.01);
    if (status == MSD_OK) {
        PRINT((char *)"");
        PRINT((char *)"*************SD PRESENTE****************");
        
        
        
        
        
        
    } else if(status == MSD_ERROR_SD_NOT_PRESENT) {
        PRINT((char *)"");
        PRINT((char *)"***********SD NON PRESENTE**************");
    }
}

void Init(void)
{
    PRINT((char *)"----------------------------------------");
    PRINT((char *)"---------DEBUT DE TRANSMISSION----------");
    PRINT((char *)"----------------------------------------");
    PRINT((char *)"");
    PRINT((char *)"----------------------------------------");
    PRINT((char *)"-------------INITIALISATION-------------");
    PRINT((char *)"----------------------------------------");
    PRINT((char *)"");
    wait(1);
    PRINT((char *)"----------------------------------------");
    PRINT((char *)"---------INITIALISATION BUS SPI---------");
    PRINT((char *)"----------------------------------------");
    cs_cap = 1;
    spi.format(8,3);
    spi.frequency(1000000);
    PRINT((char *)"");
    PRINT((char *)"***********BUS SPI INITIALISE***********");
    PRINT((char *)"");
    wait(1);    
    PRINT((char *)"----------------------------------------");
    PRINT((char *)"--------INITIALISATION CARTE SD---------");
    PRINT((char *)"----------------------------------------");
    SD();
    wait(1);
    PRINT((char *)"----------------------------------------");
    PRINT((char *)"-------INITIALISATION TOUCHSCREEN-------");
    PRINT((char *)"----------------------------------------");
    TouchScreen_Init();
    wait(1);
}

int main(void)
{
    lcd.Clear(LCD_COLOR_BLACK);
    lcd.SetBackColor(LCD_COLOR_BLACK);
    lcd.SetTextColor(LCD_COLOR_WHITE);

    Init();
    
    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");
}

I'm not sure if I was clear, I'm not good in english technical language

thanks for the help !

Question relating to:

The STM32F746G-DISCO discovery board (32F746GDISCOVERY) is a complete demonstration and development platform for STMicroelectronics ARM® Cortex®-M7 core-based STM32F746NGH6 microcontroller.

3 Answers

8 years, 8 months ago.

A working Filesystem is here: https://developer.mbed.org/users/DieterGraef/code/DISCO-F746NG_SDFileSystem/

Accepted Answer

thanks its what I was looking for !

posted by KEVIN JOUAN 16 Apr 2016
8 years, 8 months ago.

The SDFileSystem library expects to use the SD card in SPI mode (serial MOSI, MISO, SCK and CS). The PinName parameters should refer to valid portpins for SPI. I think the wiring to the microSD socket on the DISCO board is intended for the hardware supported SDMMC interface which uses a (faster) 4 bit parallel databus. These pins (PC_8 etc) are not available as SPI pins and throw a pinmap error at execution time. You have to use an external SD socket connected to valid SPI pins to use the SDFileSystem lib or find code that supports the parallel interface.

ok thanks, I saw in a other topics someone that explain the same problem with the no-spi port used

posted by KEVIN JOUAN 08 Apr 2016
8 years, 8 months ago.

I recommend you give a try to the following library and example.
It makes use of the SDMMC hardware interface:

Import librarySD_DISCO_F746NG

SD class for DISCO_F746NG platform

Import programDISCO-F746NG_SD_demo

SD for DISCO_F746NG basic demo

ok thanks, I'll give it a try

posted by KEVIN JOUAN 08 Apr 2016