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/CC3200: Read/Write user data to External Flash

Part Number: CC3200

Tool/software: TI-RTOS

Hello All

I want to read and write my custom data which is of 250 bytes in external flash.

For this i was referring the SDK example of file operations.

Now after referring the sdk example, i have few queries. can you please help me with this?

1. In the Example, in the main function i can see that the network policies are reset  before performing Flash read write, So is it compulsory to reset the network policy(Or reset the network processor ) before i read or write to flash?

2. And is there any restriction( like location to read write user data ) while writing  or reading the user data ? If yes then please help me with the exact Locations that i read or write data to.

Thanks and regards

Utkarash

  • Hi Utkarash,

    Access to serial flash is done via sl_ filesystem API. Direct access to sFlash is not supported and recommended.

    1. For reading/writing files you don't need set policies or restart NWP. It is mandatory to be NWP started by sl_Start() API only.

    2. Important information about writing user files into sFlash you find here www.ti.com/.../swra515.pdf. Important think is that sFlash have limited number of write cycles (~100k write cycles for each 4k sector).

    Other resources:
    - dev.ti.com/.../
    - www.ti.com/.../swru455 chapter 7

    Jan
  • Thank you for your Reply and Suggestions.

    I am going through documents which you have sent.

    I have used mqtt_client example as reference for developing my application code,

    In which I have used  SPI(), I2C(), UART1() for various application specific tasks,

    Where two sensors are connected via SPI and I2C respectively, and these sensor values are continuously reads and sent over UART and MQTT.

    Till this part all is working, Now I want to write/read data to external flash which i receive on UART.

    So in my application when i tried to do so the device stopped working, Whereas when i tried to write/read data to external flash, In "file_operations" example code  i was able to write/read any custom data to flash.

    However, Its mentioned that for Reading/writing to flash we use SPI, so will this effect my application's normal workflow or  Read/Write operation of Flash? as i have use SPI for Sensor Interface.

    Also I have attached my pinmux configuration function below,

    PinMuxConfig(void)
    {
    
    	// Enable Peripheral Clocks
        MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);			//I2C
    	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);
    	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA2, PRCM_RUN_MODE_CLK);
    	MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);
    	MAP_PRCMPeripheralClkEnable(PRCM_UARTA1, PRCM_RUN_MODE_CLK);
    	//******************************SPI**************************
    	MAP_PRCMPeripheralClkEnable(PRCM_GSPI, PRCM_RUN_MODE_CLK);
    	//***********************************************************
    
    
    	// Configure PIN_64 for GPIOOutput
    	MAP_PinTypeGPIO(PIN_64, PIN_MODE_0, false);
    	MAP_GPIODirModeSet(GPIOA1_BASE, 0x2, GPIO_DIR_MODE_OUT);
    
    	// Configure PIN_01 for GPIOOutput
    	MAP_PinTypeGPIO(PIN_01, PIN_MODE_0, false);
    	MAP_GPIODirModeSet(GPIOA1_BASE, 0x4, GPIO_DIR_MODE_OUT);
    
    	// Configure PIN_02 for GPIOOutput
    	MAP_PinTypeGPIO(PIN_02, PIN_MODE_0, false);
    	MAP_GPIODirModeSet(GPIOA1_BASE, 0x8, GPIO_DIR_MODE_OUT);
    
    	// Configure PIN_04 for GPIOInput
    	MAP_PinTypeGPIO(PIN_04, PIN_MODE_0, false);
    	MAP_GPIODirModeSet(GPIOA1_BASE, 0x20, GPIO_DIR_MODE_IN);
    
    	//Configure PIN_15 for GPIOInput
    	MAP_PinTypeGPIO(PIN_15, PIN_MODE_0, false);
    	MAP_GPIODirModeSet(GPIOA2_BASE, 0x40, GPIO_DIR_MODE_IN);
    
        //*******************Configuring I2C *******************
        // Configure PIN_01 for I2C0 I2C_SCL
        MAP_PinTypeI2C(PIN_01, PIN_MODE_1);
    
        // Configure PIN_02 for I2C0 I2C_SDA
        MAP_PinTypeI2C(PIN_02, PIN_MODE_1);
        //****************************************************************
    
    	// Configure PIN_55 for UART0 UART0_TX
    	MAP_PinTypeUART(PIN_55, PIN_MODE_3);
    
    	// Configure PIN_57 for UART0 UART0_RX
    	MAP_PinTypeUART(PIN_57, PIN_MODE_3);
    
    	//******************************SPI**************************
    	// Configure PIN_05 for SPI0 GSPI_CLK
    	MAP_PinTypeSPI(PIN_05, PIN_MODE_7);
    
    	// Configure PIN_06 for SPI0 GSPI_MISO
    	MAP_PinTypeSPI(PIN_06, PIN_MODE_7);
    
    	// Configure PIN_07 for SPI0 GSPI_MOSI
    	MAP_PinTypeSPI(PIN_07, PIN_MODE_7);
    
    	// Configure PIN_08 for SPI0 GSPI_CS
    	MAP_PinTypeSPI(PIN_08, PIN_MODE_7);
    	//***********************************************************
    
    	//******************Configuring UART1 ******************
    	// Configure PIN_58 for UART1 UART1_TX
    	MAP_PinTypeUART(PIN_58, PIN_MODE_6);
    
    	// Configure PIN_59 for UART1 UART1_RX
    	MAP_PinTypeUART(PIN_59, PIN_MODE_6);
    	//*****************************************************************
    
    	//************************Changes For SPI**************************
    	// Configure PIN_15 for GPIOInput
    	MAP_PinTypeGPIO(PIN_08, PIN_MODE_0, false);
    	MAP_GPIODirModeSet(GPIOA2_BASE, 0x02, GPIO_DIR_MODE_OUT);
    	//*****************************************************************
    }

    So please check and help me, whether this configuration is effecting or not.

    Please help me at the earliest.

    Thanks and regards

    Utkarash

  • Thank you for your Reply and Suggestions.

    I am going through documents which you have sent.

    I have used mqtt_client example as reference for developing my application code,

    In which I have used  SPI, I2C, UART1 for various application specific tasks,

    Where two sensors are connected via SPI and I2C respectively, and these sensor values are continuously read and sent over UART and MQTT.

    Till this part all is working, Now I want to write/read data to external flash which i receive on UART.

    So in my application when i tried to do so the device stopped working, Whereas when i tried to write/read data to external flash, In "file_operations" example code  i was able to write/read any custom data to flash.

    However, Its mentioned that for Reading/writing to flash we use SPI, so will this effect my application's normal workflow or  Read/Write operation of Flash? as i have use SPI for Sensor Interface.

    Also I have attached my pinmux configuration function below,

    PinMuxConfig(void)
    {
    
    	// Enable Peripheral Clocks
        MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);			//I2C
    	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);
    	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA2, PRCM_RUN_MODE_CLK);
    	MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);
    	MAP_PRCMPeripheralClkEnable(PRCM_UARTA1, PRCM_RUN_MODE_CLK);
    	//******************************SPI**************************
    	MAP_PRCMPeripheralClkEnable(PRCM_GSPI, PRCM_RUN_MODE_CLK);
    	//***********************************************************
    
    
    	// Configure PIN_64 for GPIOOutput
    	MAP_PinTypeGPIO(PIN_64, PIN_MODE_0, false);
    	MAP_GPIODirModeSet(GPIOA1_BASE, 0x2, GPIO_DIR_MODE_OUT);
    
    	// Configure PIN_01 for GPIOOutput
    	MAP_PinTypeGPIO(PIN_01, PIN_MODE_0, false);
    	MAP_GPIODirModeSet(GPIOA1_BASE, 0x4, GPIO_DIR_MODE_OUT);
    
    	// Configure PIN_02 for GPIOOutput
    	MAP_PinTypeGPIO(PIN_02, PIN_MODE_0, false);
    	MAP_GPIODirModeSet(GPIOA1_BASE, 0x8, GPIO_DIR_MODE_OUT);
    
    	// Configure PIN_04 for GPIOInput
    	MAP_PinTypeGPIO(PIN_04, PIN_MODE_0, false);
    	MAP_GPIODirModeSet(GPIOA1_BASE, 0x20, GPIO_DIR_MODE_IN);
    
    	//Configure PIN_15 for GPIOInput
    	MAP_PinTypeGPIO(PIN_15, PIN_MODE_0, false);
    	MAP_GPIODirModeSet(GPIOA2_BASE, 0x40, GPIO_DIR_MODE_IN);
    
        //*******************Configuring I2C *******************
        // Configure PIN_01 for I2C0 I2C_SCL
        MAP_PinTypeI2C(PIN_01, PIN_MODE_1);
    
        // Configure PIN_02 for I2C0 I2C_SDA
        MAP_PinTypeI2C(PIN_02, PIN_MODE_1);
        //****************************************************************
    
    	// Configure PIN_55 for UART0 UART0_TX
    	MAP_PinTypeUART(PIN_55, PIN_MODE_3);
    
    	// Configure PIN_57 for UART0 UART0_RX
    	MAP_PinTypeUART(PIN_57, PIN_MODE_3);
    
    	//******************************SPI**************************
    	// Configure PIN_05 for SPI0 GSPI_CLK
    	MAP_PinTypeSPI(PIN_05, PIN_MODE_7);
    
    	// Configure PIN_06 for SPI0 GSPI_MISO
    	MAP_PinTypeSPI(PIN_06, PIN_MODE_7);
    
    	// Configure PIN_07 for SPI0 GSPI_MOSI
    	MAP_PinTypeSPI(PIN_07, PIN_MODE_7);
    
    	// Configure PIN_08 for SPI0 GSPI_CS
    	MAP_PinTypeSPI(PIN_08, PIN_MODE_7);
    	//***********************************************************
    
    	//******************Configuring UART1 ******************
    	// Configure PIN_58 for UART1 UART1_TX
    	MAP_PinTypeUART(PIN_58, PIN_MODE_6);
    
    	// Configure PIN_59 for UART1 UART1_RX
    	MAP_PinTypeUART(PIN_59, PIN_MODE_6);
    	//*****************************************************************
    
    	//************************Changes For SPI**************************
    	// Configure PIN_15 for GPIOInput
    	MAP_PinTypeGPIO(PIN_08, PIN_MODE_0, false);
    	MAP_GPIODirModeSet(GPIOA2_BASE, 0x02, GPIO_DIR_MODE_OUT);
    	//*****************************************************************
    }

    So please check and help me, whether this configuration is effecting or not.

    Please help me at the earliest.

    Thanks and regards

    Utkarash

  • Hi Utkarash,

    Sorry, my mistake. I did not realize that you use CC3200, but many information from CC3220 is still valid for CC3200 as well. Most important information is about number of write cycles probably (that means sFlash cannot be used for datalogging purpose).

    Correct documents for CC3200:
    - processors.wiki.ti.com/.../CC3100_&_CC3200_Serial_Flash_Guide
    - www.ti.com/.../swru368 chapter 14

    CC3200 use for external sFlash dedicated SPI interface. From this reasons usage of SPI at application MCU does not affect access into sFlash. Usage of sl_ filesystem should not affect your other code-flow. Only you need to be sure that NWP is running before calling any sl_ API.

    Jan