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.

SDSPICC26XX driver file post failure

Other Parts Discussed in Thread: CC2650, SYSBIOS, CC1350

i am using cc2650+smartrf06eb board to develop a app,Now i want to use sd card on board over spi,  i try to post SDSPITiva.c and SDSPITiva into my project according to  the Subject"SDSPI dose not support cc26xx",I can get a SPI handle ,but no file cant be created in sdcard,other configuration is needed ? I use a example in C:\ti\tirtos_simplelink_2_13_00_06\packages\examples\source\fatsd. I rebulid a project use fatsd.c and fatsd.cfg , SPI can send a CMD,But no response from sdcard.please tell me a solution about this,thinks

  • Changjian,

    So I may better assist you, would it be possible for you to zip and upload your project?

    Derrick
  • Hi Derrick,
    I don't know how to upload my project to forum,Can you tell me?
  • Hi Derrick,
    I think my SPI cfg could be have a problem,because I don't use the DMA and Interrupt, the code as follows

    erminal I/O display like this:
    Starting the FatSD example
    Drive 0 is mounted
    Creating a new file "fat:0:input.txt"...Error: "fat:0:input.txt" could not be created.
    Please check the Getting Started Guide if additional jumpers are necessary.
    Aborting...


    board.c configuration as follow:


    /*
    * ========================== SDSPI begin ===================================
    */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(SPI_config, ".const:SPI_config")
    #pragma DATA_SECTION(spiCC26XXDMAHWAttrs, ".const:spiCC26XXDMAHWAttrs")
    #endif

    /* Include drivers */
    #include <ti/drivers/sdspi/SDSPICC2650.h>
    #include <ti/drivers/SDSPI.h>
    /* SDSPI objects */
    SDSPICC2650_Object sdspiCC2650_Object[CC2650_SPICOUNT];

    // From board.c


    /* SDSPI configuration structure, describing which pins are to be used */
    const SDSPICC2650_HWAttrs sdspiCC2650HWAttrs[CC2650_SPICOUNT] = {
    {/* SRF06EB_CC2650_SPI0 */
    .baseAddr=SSI0_BASE,

    /*! SPI Peripheral's power manager ID */
    .powerMngrId = PERIPH_SSI0,

    /*!< SSI SCK pin */
    .pinSCK=Board_SPI0_CLK,


    /*!< SSI MISO pin */
    .pinMISO=Board_SPI0_MISO,


    /*!< SSI MOSI pin */
    .pinMOSI=Board_SPI0_MOSI,

    /*!< GPIO Pin used for the chip select */
    .pinCS=Board_SPI0_CSN
    }
    };

    /* SPI configuration structure */
    const SDSPI_Config SDSPI_config[] = {
    /* SRF06EB_CC2650_SPI0 */
    {&SDSPICC2650_fxnTable, &sdspiCC2650_Object[0], &sdspiCC2650HWAttrs[0]},
    {NULL, NULL, NULL},
    };

    SDSPICC2650_open configuration as follow:

    /*
    * ======== SDSPICC2650_open ========
    * Function to mount the FatFs filesystem and register the SDSPICC2650 disk
    * I/O functions with SYS/BIOS' FatFS module.
    *
    * This function also configures some basic GPIO settings needed for the
    * software chip select with the SDCard.
    *
    * @param handle SDSPI handle
    * @param drv Drive Number
    * @param params SDSPI parameters
    */
    SDSPI_Handle SDSPICC2650_open(SDSPI_Handle handle,
    unsigned char drv,
    SDSPI_Params *params)
    {
    DRESULT dresult;
    FRESULT fresult;
    unsigned int key;
    Types_FreqHz freq;

    SDSPICC2650_Object *object = handle->object;
    SDSPICC2650_HWAttrs const *hwAttrs = handle->hwAttrs;

    /* Determine if the device was already opened */
    key = Hwi_disable();
    if (object->driveNumber != DRIVE_NOT_MOUNTED) {
    Hwi_restore(key);
    return (NULL);
    }
    /* Mark as being used */
    object->driveNumber = drv;
    Hwi_restore(key);

    /* Store the SDSPI parameters */
    if (params == NULL) {
    /* No params passed in, so use the defaults */
    params = (SDSPI_Params *) &SDSPI_defaultParams;
    }

    /* Determine time scaling for ms timeouts */
    Timestamp_getFreq(&freq);
    mSScalingFactor = freq.lo / 1000;
    Assert_isTrue(mSScalingFactor != 0, NULL);

    /* Store desired bitRate */
    object->bitRate = params->bitRate;

    IOCPinTypeSsiMaster(hwAttrs->baseAddr,hwAttrs->pinMISO,hwAttrs->pinMOSI,hwAttrs->pinCS, hwAttrs->pinSCK);//???

    /* Pin used for Chip Select */
    IOCPinTypeGpioOutput(hwAttrs->pinCS); //????

    /* Raise the chip select pin */
    GPIOPinWrite( hwAttrs->pinCS, hwAttrs->pinCS);//??

    /* Register power dependency - i.e. power up and enable clock for SPI. */
    Power_setDependency(hwAttrs->powerMngrId);


    /*
    * Configure the SPI bus to 400 kHz as required per SD specs. This frequency
    * will be adjusted later once the SD card has been successfully initialized
    */
    BIOS_getCpuFreq(&freq);
    SSIConfigSetExpClk(hwAttrs->baseAddr, freq.lo, SSI_FRF_MOTO_MODE_0,
    SSI_MODE_MASTER, 400000, 8);

    Log_print2(Diags_USER1, "SDSPI:(%p) CPU freq: %d; SDSPI freq to 400000 kHz",
    hwAttrs->baseAddr, freq.lo);

    SSIEnable(hwAttrs->baseAddr);

    /* Register the new disk_*() functions */
    dresult = disk_register(object->driveNumber,
    SDSPICC2650_diskInitialize,
    SDSPICC2650_diskStatus,
    SDSPICC2650_diskRead,
    SDSPICC2650_diskWrite,
    SDSPICC2650_diskIOctrl);

    /* Check for drive errors */
    if (dresult != RES_OK) {
    Log_error1("SDSPI:(%p) disk functions not registered",
    hwAttrs->baseAddr);

    SDSPICC2650_close(handle);
    return (NULL);
    }

    /*
    * Register the filesystem with FatFs. This operation does not access the
    * SDCard yet.
    */
    fresult = f_mount(object->driveNumber, &(object->filesystem));
    if (fresult != FR_OK) {
    Log_error2("SDSPI:(%p) drive %d not mounted",
    hwAttrs->baseAddr, object->driveNumber);

    SDSPICC2650_close(handle);
    return (NULL);
    }

    /* Store the new SDSPI handle for this FatFs drive number */
    sdspiHandles[drv] = handle;

    Log_print1(Diags_USER1, "SDSPI:(%p) opened", hwAttrs->baseAddr);

    return (handle);
    }

    .cfg file

    /*
    * Copyright (c) 2015, Texas Instruments Incorporated
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    * * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */

    /*
    * ======== fatsd.cfg ========
    */

    /* ================ General configuration ================ */
    var Defaults = xdc.useModule('xdc.runtime.Defaults');
    var Diags = xdc.useModule('xdc.runtime.Diags');
    var Error = xdc.useModule('xdc.runtime.Error');
    var Log = xdc.useModule('xdc.runtime.Log');
    var Main = xdc.useModule('xdc.runtime.Main');
    var Memory = xdc.useModule('xdc.runtime.Memory');
    var System = xdc.useModule('xdc.runtime.System');
    var Text = xdc.useModule('xdc.runtime.Text');

    var Task = xdc.useModule('ti.sysbios.knl.Task');
    var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
    var FatFS = xdc.useModule('ti.sysbios.fatfs.FatFS');


    /*
    * Program.stack is ignored with IAR. Use the project options in
    * IAR Embedded Workbench to alter the system stack size.
    */
    if (!Program.build.target.$name.match(/iar/)) {
    /*
    * Reducing the system stack size (used by ISRs and Swis) to reduce
    * RAM usage.
    */
    Program.stack = 0x300;
    }

    /*
    * Comment this line to allow module names to be loaded on the target.
    * The module name strings are placed in the .const section. Setting this
    * parameter to false will save space in the .const section. Error and
    * Assert messages will contain an "unknown module" prefix instead
    * of the actual module name.
    */
    Defaults.common$.namedModule = false;

    /*
    * Minimize exit handler array in System. The System module includes
    * an array of functions that are registered with System_atexit() to be
    * called by System_exit().
    */
    System.maxAtexitHandlers = 2;

    /*
    * Comment this line to allow Error, Assert, and Log strings to be
    * loaded on the target. These strings are placed in the .const section.
    * Setting this parameter to false will save space in the .const section.
    * Error, Assert and Log message will print raw ids and args instead of
    * a formatted message.
    */
    Text.isLoaded = false;

    /* ================ System configuration ================ */
    var SysMin = xdc.useModule('xdc.runtime.SysMin');
    System.SupportProxy = SysMin;

    /* Enable Semihosting for GNU targets to print to CCS console */
    if (Program.build.target.$name.match(/gnu/)) {
    var SemiHost = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');
    }

    /* ================ BIOS configuration ================ */
    /*
    * Disable unused BIOS features to minimize footprint.
    */
    var BIOS = xdc.useModule('ti.sysbios.BIOS');
    BIOS.libType = BIOS.LibType_Custom;
    BIOS.logsEnabled = false;
    BIOS.assertsEnabled = false;

    /* Reduce the heap size */
    BIOS.heapSize = 0x1000;

    /* Runtime stack checking is performed */
    Task.checkStackFlag = true;
    Hwi.checkStackFlag = true;

    /* Reduce the number of task priorities */
    Task.numPriorities = 4;

    /* Remove the Idle Task */
    Task.enableIdleTask = false;

    /* ================ Task configuration ================ */
    var task0Params = new Task.Params();
    task0Params.instance.name = "fatSDTask";
    task0Params.stackSize = 0x400;
    Program.global.task = Task.create("&taskFxn", task0Params);

    /* ================ Driver configuration ================ */
    var TIRTOS = xdc.useModule('ti.tirtos.TIRTOS');
    TIRTOS.useGPIO = true;
    TIRTOS.useSDSPI = true;

    if (Program.cpu.deviceName.match(/CC26/)) {
    var Power = xdc.useModule('ti.sysbios.family.arm.cc26xx.Power');
    var Boot = xdc.useModule('ti.sysbios.family.arm.cc26xx.Boot');
    Boot.customerConfig = true;
    var ROM = xdc.useModule('ti.sysbios.rom.ROM');
    ROM.romName = ROM.CC2650;
    }
    else if (Program.cpu.deviceName.match(/CC13/)) {
    var Power = xdc.useModule('ti.sysbios.family.arm.cc26xx.Power');
    var Boot = xdc.useModule('ti.sysbios.family.arm.cc26xx.Boot');
    Boot.customerConfig = true;
    var ROM = xdc.useModule('ti.sysbios.rom.ROM');
    ROM.romName = ROM.CC1350;
    }
  • Changjian,

    When you press reply, you will see an option to "Use Rich Formatting". From there, you will be able to add an attachment via the 'paperclip' icon.

    Derrick

  • 3678.SD_SPI.zip

    I have uploaded my project..If you meet a problem when compiling or linking,you can ask me, Thinks for you help again.

  • Changjian,

    Where do you configure the GPIO pins for the SPI Bus? Also, are you remembering to enable the SSI peripheral?

    Could you also include your files: SDSPICC2650.c & SDSPICC2650.h?

    Derrick
  • Hi Derrick,
    You need to rebuild a path for the project, you can read the readme.txt in folder. I have included the flie: SDSPICC2650.c &SDSPICC2650.h,and SPI is working ,I can see waveform by oscilloscope and the SPI time sequence is right by sending a command.
  • Changjian,

    I am taking a look at your SSPICC2650 files.

    In the meantime, are you using a SD BoosterPack? I'd recommend double checking your pin connections.

    If you are able to communicate to the SD card via SPI, then you need to ensure that you're following the guidelines set forth by the SD Simplified Specifications. Page 178 is the beginning of the SPI Mode section of this document.

    Derrick

  • Changjian,

    Could you try configuring your MISO, MOSI and CLK pins as simply:

    Board_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN,
    Board_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN,
    Board_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN,

    I see your Chip Select pin is being configured in fatsd.c

    Derrick

  • Hello, 

    You create the functions and the file SDSPICC2650.c , but you never call its functions. 

    This seems strange to me and possibly this is the problem. Did you finally find a solution? 

  • Hi,
    We generally discourage posting a new question to an old closed thread because the person who answered before may no longer be available, and also it will allow whomever is currently assigned to monitor the forum to respond to you more quickly. For these reasons, I suggest you start a new thread with your question and reference this thread.

    Thanks
  • Hello,
    yes, i have solved the problem,now the SDSPICC2650 is working wll, my problem is that the pin is not welded well.