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.

LAUNCHXL-CC2650: External flash SPI code causes problem in reading other gpio pins

Part Number: LAUNCHXL-CC2650
Other Parts Discussed in Thread: CC2650, CC2640

Hello,

I am using LAUNCHXL-CC2650

BLE SDK 2_02_07_06

CCS7.4

Compiler TI Ver.5.2.6.

I have connected display which is using gpio DIO7 pin and I am also reading external flash chip.

I can read ext flash without any issue but when I read gpio DIO7 my code hangs.

When I comment the ext flash reading code I can read the Gpio DIO7 without problem.

Please guide me to solve this problem

My external flash code is based on "bim_extflash" project.

Thank you

Dnyaneshvar salve

  • while debugging I came to know that

    void bspSpiClose(void) function disabling clock and power of GPIO module

    I modified the code as shown below and after that display and Ext flash data read also worked. 

    /* See bsp_spi.h file for description */
    //************** THIS IS UNMODIFIED CODE
    void bspSpiClose(void)
    {
      // Power down SSI0
      ROM_PRCMPeripheralRunDisable(PRCM_PERIPH_SSI0);
      PRCMLoadSet();
      while (!PRCMLoadGet());
    
      PRCMPeripheralRunDisable(PRCM_PERIPH_GPIO);
      PRCMLoadSet();
      while (!PRCMLoadGet());
    
      PRCMPowerDomainOff(PRCM_DOMAIN_SERIAL | PRCM_DOMAIN_PERIPH);
      while (PRCMPowerDomainStatus(PRCM_DOMAIN_SERIAL | PRCM_DOMAIN_PERIPH)
             != PRCM_DOMAIN_POWER_OFF);
    }

    /* See bsp_spi.h file for description */
    //************** THIS IS MODIFIED CODE
    void bspSpiClose(void)
    {
      // Power down SSI0
      ROM_PRCMPeripheralRunDisable(PRCM_PERIPH_SSI0);
      PRCMLoadSet();
      while (!PRCMLoadGet());
    
    //  PRCMPeripheralRunDisable(PRCM_PERIPH_GPIO);
    //  PRCMLoadSet();
    //  while (!PRCMLoadGet());
    
    //  PRCMPowerDomainOff(PRCM_DOMAIN_SERIAL | PRCM_DOMAIN_PERIPH);
    //  while (PRCMPowerDomainStatus(PRCM_DOMAIN_SERIAL | PRCM_DOMAIN_PERIPH)
    //         != PRCM_DOMAIN_POWER_OFF);
    
      PRCMPowerDomainOff(PRCM_DOMAIN_SERIAL);
      while (PRCMPowerDomainStatus(PRCM_DOMAIN_SERIAL)
             != PRCM_DOMAIN_POWER_OFF);
    }

    I have allowed power and clock to GPIO module by editing the above code section.

  • Due to above changes display and Ext flash chip worked but now CC2650 is not able to advertise. I am not able to see my device when scanned using BLE scanner or other BLE apps.

    So I commented the  extFlashClose(); function.

    CC2650 started advertising again due to this.

    But the problem is if I don't call  extFlashClose(); my External flash chip will not go into sleep mode (my product is coin cell based)

    Please help

  • Hello Dnyaneshvar,

    I am sending this to the relevant expert, they should get back to you by tomorrow.

    Kind Regards,

    Rogelio

  • Hi Dnyaneshvar salve,

    Thank you for reaching out. Can you specify which example project you are using for your development? I suggest taking a look at the following E2E thread: https://e2e.ti.com/f/1/t/462572

    The linked E2E thread provides some insight into how to use both SPI interfaces on the device which may be helpful here.

    Best Regards,

    Jan

  • Hello j,

    I think I have confused you. Let's start with fresh details.

    It is not about using Dual SPI. My display is using SOFTWARE SPI and the SPI peripheral of CC2650 is only being used for external flash chip.

    I am using "Simple BLE peripheral" example project as an base code for development.

    In this example project I have added external flash read-write code based on "bim_extflash" project. My project's build configuration is "FlashRom".

    I have written test code to access External flash chip in main.c.

    The problem is "extFlashClose()" function.

    If I call this function extFlashClose() (before BIOS_start()) then CC2650 BLE does not advertise.

    and if I comment the function "extFlashClose()" CC2650 BLE starts advertising

  • Hi Dnyaneshvar ,

    Thank you for clarifying. If you place the extFlashClose() function after the BIOS_start(), is the same behavior observed?

    Best Regards,

    Jan

  • Hello Jan,

    I have tested as said by you.

    I  called the  extFlashClose() function after BIOS_start() function.

    I am calling extFlashClose() function in simple_peripheral.c.

    But the results are same if I comment  extFlashClose() BLE advertises and if I uncomment  extFlashClose() I can discover this BLE device

  • Hi,

    Got it. Looking through E2E, I have found this thread which seems to describe similar behavior to the one you are seeing (no advertising): https://e2e.ti.com/f/1/t/1034296/

    To confirm, are you sing the ext_flash.c and ext_flash.h that are found in the "C:\ti\simplelink\ble_sdk_2_02_06_07\src\examples\util\bim_extflash\cc2640\board." directory or the directory mentioned by Ammar in the other thread?

    Best Regards,

    Jan

  • Hi Jan,

    I want to confirm that I was using 

    ext_flash.c and ext_flash.h that are found in the "C:\ti\simplelink\ble_sdk_2_02_07_06\src\examples\util\bim_extflash\cc2640\board."

    I looked at https://e2e.ti.com/f/1/t/1034296/  sa suggested by you and copied files from

    "tirtos_cc13xx_cc26xx_2_21_01_08\products\tidrivers_cc13xx_cc26xx_2_21_01_01\packages\ti\mw\extflash".

    Now, while executing code control is getting stuck at SPI_transfer function and not returning back. Code hangs there.

    bool SPI_transfer(SPI_Handle handle, SPI_Transaction *transaction)
    {
        return (handle->fxnTablePtr->transferFxn(handle, transaction));//here is the problem
    }

    Actually When 6 months ago when at first time I was coding for External flash, I had used files mentioned above. and I got errors.

    Story is in this link

    https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1121433/launchxl-cc2650-extflashopen-fail-in-cc2650-simple-ble-peripheral-example/4168660?tisearch=e2e-sitesearch&keymatch=%2525252520user%252525253A508658#4168660

    and later I ended up using BIM project - ("C:\ti\simplelink\ble_sdk_2_02_07_06\src\examples\util\bim_extflash\cc2640\board") as as reference project and successfully accessed External flash memory.

    But eventually I have came to a point from where I had started before 6 months.

    So can you please guide me.

    while executing code control is getting stuck at SPI_transfer function and not returning back. Code hangs there. you can refer above link for details of the errors with screenshots.

    Dnyaneshvar salve

  • Hi Dnyaneshvar,

    Got it. Thank you for providing additional context! Can you share the SPI setup parameters you are using? Maybe the parameters may provide some insight into what may be going on here.

    Best Regards,

    Jan

  • Hi Jan,

    SPI setup parameters are as below

    /* Default SPI parameters structure */
    const SPI_Params SPI_defaultParams = {
    SPI_MODE_BLOCKING, /* transferMode */
    SPI_WAIT_FOREVER, /* transferTimeout */
    NULL, /* transferCallbackFxn */
    SPI_MASTER, /* mode */
    1000000, /* bitRate */
    8, /* dataSize */
    SPI_POL0_PHA0, /* frameFormat */
    (uintptr_t) NULL /* custom */
    };

    later 

    #define SPI_BIT_RATE              4000000

    void SPI_Params_init(SPI_Params *params)
    {
        *params = SPI_defaultParams;
    }

     

    static bool Spi_open(uint32_t bitRate)
    {
    /* Configure SPI as master */
    SPI_Params_init(&spiParams);
    spiParams.bitRate = bitRate;
    spiParams.mode = SPI_MASTER;
    spiParams.transferMode = SPI_MODE_BLOCKING;
    
    /* Attempt to open SPI. */
    spiHandle = SPI_open(Board_SPI0, &spiParams);
    
    return spiHandle != NULL;
    }

    Dnyaneshvar

  • Hi Dnyaneshvar,

    When the transfer function is called, do you see any activity on the SPI pins? Can you try changing the transfer more to callback to see if the same behavior is observed?

    Best Regards,

    Jan