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.

CCS/CC2650: cc2650 LAUNCHPAD

Part Number: CC2650

Tool/software: Code Composer Studio

Hello,

I'm extending the Zero Project and want it to use the flash memory on the board.

I'm using ExtFlash.h api.

My code looks as following:

static bool ExtFlash_init(void)
{
    if (!ExtFlash_open()) {
        return false;
    }
    ExtFlashInfo_t* extFalshInfo = ExtFlash_info();
    Log_info3("Opened extflash device (size: %d, dev id: %d, manf id: %d)", extFalshInfo->deviceSize, extFalshInfo->devId, extFalshInfo->manfId);
    return true;
}

static void ExtFlash_testForRead(void)
{
    uint8_t buffer[11] = {0};
    if (!ExtFlash_read(0, sizeof(buffer) - 1, buffer)) {
        Log_error0("Read failed!");
        return;
    }
}

static void ProjectZero_init(void)
{
  if (!ExtFlash_init()) {
      Log_error0("Error initializing ExtFlash");
      Task_exit();
  }
  Log_info0("Extflash initialized");

  ExtFlash_testForRead();
  
  /* ALL OTHER PROJECT ZERO INIT CODE */
}

The problem is that once I run the ExtFlash_read function, I get stuck and the application doesn't continue...

In addition, I don't get any UART logs before and after the ExtFlash_read function (I guess it's because flushing stuff, how can I manually flush?)

Thanks in advance.

  • Make sure you use correct SPI CS, SCLK, MOSI, and MISO pin define for your external flash.

  • I'm using the configuration which is in the ExtFlash.c file:

    static PIN_Config BoardFlashPinTable[] =
    {
        Board_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* Ext. flash chip select */
    
        PIN_TERMINATE
    };
    
    bool ExtFlash_open(void)
    {
        bool f;
    
        hFlashPin = PIN_open(&pinState, BoardFlashPinTable);
    
        if (hFlashPin == NULL)
        {
            return false;
        }
    
        /* Make sure SPI is available */
        f = Spi_open(SPI_BIT_RATE);
    
        if (f)
        {
            /* Put the part is standby mode */
            f = extFlashPowerStandby();
    
            if (f)
            {
                /* Verify manufacturer and device ID */
                f = extFlashVerifyPart();
            }
    
            if (!f)
            {
                ExtFlash_close();
            }
        }
    
        return f;
    }
    

    But actually ExtFlash_open works, and it gets stuck while ExtFlash_read in SPICC26XXDMA.c:

    bool SPICC26XXDMA_transfer(SPI_Handle handle, SPI_Transaction *transaction)
    {
        // Lots of code
        // Here! stuck on semaphore pend....
        if (!Semaphore_pend(Semaphore_handle(&(object->transferComplete)), object->transferTimeout)) {
    }

  • Do you check if Flash CS, SCLK, MOSI, and MISO pins is mapped to correct IDIO in your code?
  • I really don't know how to check this...

    In the project zero code:

    /************************* 
    *** CC2650_LAUNCHXL.h ****
    *************************/
    
    /* Discrete inputs */
    #define Board_BTN1                  IOID_13
    #define Board_BTN2                  IOID_14
    
    /* UART Board */
    #define Board_UART_RX               IOID_2          /* RXD  */
    #define Board_UART_TX               IOID_3          /* TXD  */
    #define Board_UART_CTS              IOID_19         /* CTS  */
    #define Board_UART_RTS              IOID_18         /* RTS */
    
    /* SPI Board */
    #define Board_SPI0_MISO             IOID_8          /* RF1.20 */
    #define Board_SPI0_MOSI             IOID_9          /* RF1.18 */
    #define Board_SPI0_CLK              IOID_10         /* RF1.16 */
    #define Board_SPI0_CSN              PIN_UNASSIGNED
    #define Board_SPI1_MISO             PIN_UNASSIGNED
    #define Board_SPI1_MOSI             PIN_UNASSIGNED
    #define Board_SPI1_CLK              PIN_UNASSIGNED
    #define Board_SPI1_CSN              PIN_UNASSIGNED
    
    /* I2C */
    #define Board_I2C0_SCL0             IOID_4
    #define Board_I2C0_SDA0             IOID_5
    
    /* SPI */
    #define Board_SPI_FLASH_CS          IOID_20
    #define Board_FLASH_CS_ON           0
    #define Board_FLASH_CS_OFF          1
    
    
    /****************** 
    *** ExtFlash.c ****
    ******************/
    
    static PIN_Config BoardFlashPinTable[] =
    {
        Board_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* Ext. flash chip select */
    
        PIN_TERMINATE
    };
    
    /************************* 
    *** CC2650_LAUNCHXL.c ****
    *************************/
    
    const PIN_Config BoardGpioInitTable[] = {
    
        Board_RLED   | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,         /* LED initially off             */
        Board_GLED   | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,         /* LED initially off             */
        Board_BTN1   | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,            /* Button is active low          */
        Board_BTN2   | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,            /* Button is active low          */
        Board_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN,  /* External flash chip select    */
        Board_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN,                                              /* UART RX via debugger back channel */
        Board_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,                        /* UART TX via debugger back channel */
        Board_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN,                                            /* SPI master out - slave in */
        Board_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN,                                            /* SPI master in - slave out */
        Board_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN,                                             /* SPI clock */
    
        PIN_TERMINATE
    };
    

    I'm really helpless... What are the right values of those macros?

  • Your SPI CS, SCLK, MOSI, and MISO defines are fine. Try to remove the following three lines from BoardGpioInitTable[].

    Board_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */

    Board_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */

    Board_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */

  • I've tried to remove them, but it doesn't change the behaviour.
  • Do you use LAUNCHXL-CC2650 to test this external flash read/write?
  • Yes, as I said, I'm trying to extend project zero code with ExtFlash. Therefore in the project zero task the very first thing I do is to test the read functionality from the flash.

    I tested it with my CC2650 launchpad board, with debugging mode and without, in both cases it gets stuck on the line I mentioned earlier.

  • I test similar things on my LAUNCHXL-CC2650 and it works fine. I attached my code and you can copy it to your \ProjectZeroApp_CC2650LAUNCHXL\Application to test it.

    5074.Application.zip

  • Thanks it worked.
    Please notice that in ext_flash.c you use GPIOPinWrite function, which wasn't declared in my <driverlib/gpio.h>, I change it to GPIO_writeDio, I hope it is fine :)

    Thanks for your help I really appreciate it, If you find out what was wrong with my code (maybe because I used ExtFlash api and not ext_flash...) I will be glad if you can tell me.

    P.S. Is there any function like ExtFlash_info with this API?
  • I tried to play with it a little bit, but please notice the when I switch between the read and the write functions, rbuffer is still contains only 0x00 and not 0x12345678!
    Looking at the extFlashWrite function, it actually can't fail (return code is always 0), so therefore I can't tell if 0x12345678 was written or not.
    I don't think this code works.....
  • I run the code on my LAUNCHXL-CC2650 and I am pretty sure it works fine. Do you use my attached ext_flash.c? If you have a look at extFlashWrite function in it, it can return true or false.
  • extFlashWrtie indeed returns true or false, but if we look at extFlashWrite we see that the actually writing is done by bspSpiWrite and if it fails it returns non zero value, but the bspSpiWrite function always returns 0!

    Please switch places between your extFlashRead and extFlashWrite calls and check if rbuffer contains wbuffer values. My rbuffer still contains null bytes only...

  • If you look at my example code, I set rbuffer to 0x0 when initialization.

    int8_t rbuffer[4] = {0x0,0x0,0x0,0x0};

    I can see "rbuffer[4] = {0x0,0x0,0x0,0x0}" before I call "if (!extFlashRead(0, 4, rbuffer)){...}" and rbuffer becomes "{0x12,0x34,0x56,0x78}" after I call "if (!extFlashRead(0, 4, rbuffer)){...}". I am sure the code works fine.