This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/MSP432P401R: SPI + SD card error

Part Number: MSP432P401R

Tool/software: TI-RTOS

Hi,

I have a project that needs to read some data over SPI and than write it on the SD card.

Reading from SPI works, writing to the SD card also (separately).

The problem is that I cannot read correctly the data of the SPI sensor after I init the SD card.

If I don't call the mount function I'm able to read the data normally. If I call mount function the SPI data is strange.. 

void mount() {
    /* Mount and register the SD Card */
    SDSPI_Params_init(&sdspiParams);
    sdspiHandle = SDSPI_open(Board_SDSPI0, DRIVE_NUM, &sdspiParams);
    if (sdspiHandle == NULL) {
        System_printf("Error starting the SD card\n");
        System_flush();
        while (1);
    } else {
        System_printf("Drive %u is mounted\n", DRIVE_NUM);
        System_flush();
    }
}

Any help?

Version:
Simplelink 1.30

  • Hello,

    user4504050 said:
    The problem is that I cannot read correctly the data of the SPI sensor after I init the SD card.

    It looks like you are using the same SPI interface to talk to the SPI sensor and the SD Card, could you please share the SPI connections between:

    MSP432 and the Sensor

    MSP432 and the SD Card

    Also, please share your SPI initialization code for the sensor and the SD Card.

      Thanks,

       David

  • The only thing that I've changed is this:

    const SDSPIMSP432_HWAttrsV1 sdspiMSP432HWAttrs[MSP_EXP432P401R_SDSPICOUNT] = {
    
        {
    
            /* CLK, MOSI & MISO ports & pins */
    
    
    
            .baseAddr = EUSCI_B0_BASE,
    
            .clockSource = EUSCI_B_SPI_CLOCKSOURCE_SMCLK,
    
            .sckPin = SDSPIMSP432_P3_5_UCB0CLK,
    
            .somiPin = SDSPIMSP432_P3_7_UCB0SOMI,
    
            .simoPin = SDSPIMSP432_P3_6_UCB0SIMO,
    
            /* Chip select port & pin */
    
            .csPin = SDSPIMSP432_P5_1_CS
    
        }
    
    };

    From this:

    const SDSPIMSP432_HWAttrsV1 sdspiMSP432HWAttrs[MSP_EXP432P401R_SDSPICOUNT] = {
        {
            /* CLK, MOSI & MISO ports & pins */
    
            .baseAddr = EUSCI_B0_BASE,
            .clockSource = EUSCI_B_SPI_CLOCKSOURCE_SMCLK,
            .sckPin = SDSPIMSP432_P1_5_UCB0CLK,
            .somiPin = SDSPIMSP432_P1_7_UCB0SOMI,
            .simoPin = SDSPIMSP432_P1_6_UCB0SIMO,
    
            /* Chip select port & pin */
            .csPin = SDSPIMSP432_P4_6_CS
        }
    }

    After that I noticed that the SPI0 reads the data from the SD card which is configured like above.

    SPI Initialization(Sensor/Ram..)

    //************************************************************
    //  @summary: Init SPI
    //  @param: None
    //  @return: None
    //************************************************************
    void FRAM_Init_SPI(){
    
        SPI_Params spiParams;
    
        /* Initialize SPI handle with slave mode */
        SPI_Params_init(&spiParams);
        spiParams.frameFormat = SPI_POL0_PHA1;
    
        masterSpi = SPI_open(Board_SPI0, &spiParams);
        if (masterSpi == NULL) {
            System_abort("Error initializing SPI\n");
            System_flush();
        } else {
            System_printf("SPI initialized\n");
            System_flush();
        }
    
    }

    SD Card init...

        /* Mount and register the SD Card */
        SDSPI_Params_init(&sdspiParams);
        sdspiHandle = SDSPI_open(Board_SDSPI0, DRIVE_NUM, &sdspiParams);
        if (sdspiHandle == NULL) {
            System_printf("Error starting the SD card\n");
            System_flush();
            while (1);
        } else {
            System_printf("Drive %u is mounted\n", DRIVE_NUM);
            System_flush();
        }


    It seams like that after mounting the SD card the SPI0 reads the MISO(3_7) from the SD card instead of the SPI0(1_7).

  • Hello,

     Please try changing your SDSPIMSP432_HWAttrsV1 sdspiMSP432HWAttrs to use EUSCI_B2_BASE.

    const SDSPIMSP432_HWAttrsV1 sdspiMSP432HWAttrs[MSP_EXP432P401R_SDSPICOUNT] = {
        {
            .baseAddr = EUSCI_B2_BASE,
            .clockSource = EUSCI_B_SPI_CLOCKSOURCE_SMCLK,
    
            /* CLK, MOSI & MISO ports & pins */
            .sckPin = SDSPIMSP432_P3_5_UCB2CLK,
            .somiPin = SDSPIMSP432_P3_7_UCB2SOMI,
            .simoPin = SDSPIMSP432_P3_6_UCB2SIMO,
    
            /* Chip select port & pin */
            .csPin = SDSPIMSP432_P5_1_CS
        }
    };

    Hopefully that should do the trick.

      Best regards,

       David

  • It Works!

    Thank you David.

**Attention** This is a public forum