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.

CC2652R: Problem with External Flash

Part Number: CC2652R
Other Parts Discussed in Thread: Z-STACK, , LAUNCHXL-CC26X2R1

Hello,

I am using a custom designed board which uses the cc2652r and I am not able to read or write anything on to the external flash in the Z-stack Application layer. I intend to use the Flash for OTA. The Flash is being detected in the bim project and factory image is copied.  

SDKs used:

1) simplelink_cc26x2_sdk_2_20_00_36

2) simplelink_zigbee_sdk_plugin_2_20_00_06

Example Project on which Custom application is developed: zed_switch_ota .(built on IAR EW Arm 8.30.1)

Below is the Flash Pin Configuration modified as per custom board that we designed. 

Default Configuration DIO/IOID Custom Configuration DIO/IOID
CC26X2R1_LAUNCHXL_SPI_FLASH_CS IOID_20 CC26X2R1_LAUNCHXL_SPI_FLASH_CS IOID_10
CC26X2R1_LAUNCHXL_SPI0_MISO IOID_8 CC26X2R1_LAUNCHXL_SPI0_MISO IOID_9
CC26X2R1_LAUNCHXL_SPI0_MOSI IOID_9 CC26X2R1_LAUNCHXL_SPI0_MOSI IOID_11
CC26X2R1_LAUNCHXL_SPI0_CLK IOID_10 CC26X2R1_LAUNCHXL_SPI0_CLK IOID_12

have modified the SPI pin settings in 

C:\ti\simplelink_cc26x2_sdk_2_20_00_36\examples\rtos\CC26X2R1_LAUNCHXL\ti154stack\common\boards\CC26X2R1_LAUNCHXL\CC26X2R1_LAUNCHXL.h 

C:\ti\simplelink_zigbee_sdk_plugin_2_20_00_06\examples\rtos\CC26X2R1_LAUNCHXL\zstack\common\boards\CC26X2R1_LAUNCHXL\CC26X2R1_LAUNCHXL_OAD.h 

  • Hello Prem,

    Your custom configuration at least conflicts with the on-board MX25R8035F's MOSI and CLK pins, I recommend that you at least match the pin functions (since SPI bus communication is allowed) or remove the Flash PWR resistor on the LaunchPad (so that the on-board external flash does not interfere). As the MX25R8035F already uses SPI0 you should consider using SPI1 instaed to avoid further conflict. It would help if you specified what all code changes were made, what functions are used, and oscilloscope/logic analyzer or debugger screenshots of your efforts. No changes are required to the ti154stack folder.

    Regards,
    Ryan
  • following changes done for custom hardware-

    In bsp.h

    // Board external flash defines
    #define BSP_IOID_FLASH_CS       IOID_10
    #define BSP_SPI_MOSI            IOID_11
    #define BSP_SPI_MISO            IOID_9
    #define BSP_SPI_CLK_FLASH       IOID_12
    

    In CC26X2R1_LAUNCHXL_OAD.h

    /* SPI */
    #define CC26X2R1_LAUNCHXL_SPI_FLASH_CS          IOID_10
    #define CC26X2R1_LAUNCHXL_FLASH_CS_ON           0
    #define CC26X2R1_LAUNCHXL_FLASH_CS_OFF          1
    
    /* SPI Board */
    #define CC26X2R1_LAUNCHXL_SPI0_MISO             IOID_9         /* RF1.20 */
    #define CC26X2R1_LAUNCHXL_SPI0_MOSI             IOID_11         /* RF1.18 */
    #define CC26X2R1_LAUNCHXL_SPI0_CLK              IOID_12         /* RF1.16 */

    In CC26X2R1_LAUNCHXL.h

    /* SPI */
    #define CC26X2R1_LAUNCHXL_SPI_FLASH_CS          IOID_10
    #define CC26X2R1_LAUNCHXL_FLASH_CS_ON           0
    #define CC26X2R1_LAUNCHXL_FLASH_CS_OFF          1
    
    /* SPI Board */
    #define CC26X2R1_LAUNCHXL_SPI0_MISO             IOID_9          /* RF1.20 */
    #define CC26X2R1_LAUNCHXL_SPI0_MOSI             IOID_11        /* RF1.18 */
    #define CC26X2R1_LAUNCHXL_SPI0_CLK              IOID_12        /* RF1.16 */


    Rest all pins are configured as PIN_UNASSIGNED

    basic problem with custom hardware is that ota update is getting aborted.

    But when we use command 0x90h (Read Electronic Manufacturer ID & Device ID (REMS))

    we get correct id - 

    manfId = 0xC2
    devId = 0x14

  • My mistake, I had not read the part where you are using custom hardware. Since the SPI communication is functional the next step is to debug your firmware and discover why the OTA update is getting aborted.

    Regards,
    Ryan

  • we have not modified anything in the code except pin configuration.

    to test SPI interface we use below approach and it works.

              bspSpiOpen(4000000, BSP_SPI_CLK_FLASH);   
              IOCPinTypeGpioOutput(BSP_IOID_FLASH_CS);
         
          uint8_t infoBuf[2];
        const uint8_t wbuf[] = { 0x90, 0xFF, 0xFF, 0x00 };
           GPIO_clearDio(BSP_IOID_FLASH_CS);
           bspSpiFlush();
           
           bspSpiWrite(wbuf, sizeof(wbuf));
           
           bspSpiRead(infoBuf, sizeof(infoBuf));
           printf("manufacture id = %x\n" ,infoBuf[0]);
           printf("dev id = %x\n" ,infoBuf[1]);
         GPIO_setDio(BSP_IOID_FLASH_CS);
           bspSpiClose();
    

    To further debug when we try to use the below approach we are not able to do read/ write.

           
              flash_init();
         
          uint8_t infoBuf[2];
         uint8_t wbuf[] = { 0x12, 0x14 };
    
          flash_open();
    
           printf(" check 1\n");
    
           writeFlash(0x000000, wbuf, 2);
    
           printf(" check 2\n");
        
           readFlash(0x000000,infoBuf, 2);
           printf("byte 1 = %x\n" ,infoBuf[0]);
           printf("byte 2 = %x\n" ,infoBuf[1]);
           flash_close();

  • Do you use Protocol Analyzer or scope to check if SPI singal is correct on your SPI pins?
  • since we are able to read device id and manufacture id by sending command 0x90h (Read Electronic Manufacturer ID & Device ID (REMS))
    I think issue is not with SPI interface.
  • So then would you believe this is an issue with the flash functions you included in your code snippet? Are you using the SPI TI Drivers and referencing the appropriate code examples? Have you tried using a ZR project which does not go to sleep?

    Regards,
    Ryan
  • Changes required in CC26X2R1_LAUNCHXL_OAD.c  in the section mentioned below-

    /*
     *  =============================== GPIO ===============================
     */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/gpio/GPIOCC26XX.h>
    
    /*
     * Array of Pin configurations
     * NOTE: The order of the pin configurations must coincide with what was
     *       defined in CC26X2R1_LAUNCHXL.h
     * NOTE: Pins not used for interrupts should be placed at the end of the
     *       array. Callback entries can be omitted from callbacks array to
     *       reduce memory usage.
     */
    GPIO_PinConfig gpioPinConfigs[] = {
        /* Input pins */
        GPIOCC26XX_DIO_05 | GPIO_DO_NOT_CONFIG,  /* Button 0 */
        GPIOCC26XX_DIO_06 | GPIO_DO_NOT_CONFIG,  /* Button 1 */
    
        GPIOCC26XX_DIO_15 | GPIO_DO_NOT_CONFIG,  /* CC26X2R1_LAUNCHXL_SPI_MASTER_READY */
        GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG,  /* CC26X2R1_LAUNCHXL_SPI_SLAVE_READY */
    
        /* Output pins */
        GPIOCC26XX_DIO_29 | GPIO_DO_NOT_CONFIG,  /* Green LED */
        GPIOCC26XX_DIO_28 | GPIO_DO_NOT_CONFIG,  /* Red LED */ 
    
        /* SPI Flash CSN */
        GPIOCC26XX_DIO_10 | GPIO_DO_NOT_CONFIG,    // Modified for custom hardware
    
        /* SD CS */
        GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG,
    
        /* Sharp Display - GPIO configurations will be done in the Display files */
        GPIOCC26XX_DIO_24 | GPIO_DO_NOT_CONFIG, /* SPI chip select */
        GPIOCC26XX_DIO_22 | GPIO_DO_NOT_CONFIG, /* LCD power control */
        GPIOCC26XX_DIO_23 | GPIO_DO_NOT_CONFIG, /*LCD enable */
    
    };
    

  • Since I do not have your custom hardware, I would either need to know exactly how to replicate this issue on a LAUNCHXL-CC26X2R1 or be provided with further insight into the issue based on the questions asked.

    Regards,
    Ryan
  • The issue is resolved...
    To configure SPI pins for ext flash ..changes required in three files
    1) CC26X2R1_LAUNCHXL_OAD.c
    2)CC26X2R1_LAUNCHXL.h
    3)CC26X2R1_LAUNCHXL_OAD.h