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.

TM4C129ENCPDT: Using part of flash memory to use as RAM

Part Number: TM4C129ENCPDT

Hi All,

I am using the tm4c129encpdt microcontroller with TI-RTOS. 

I have one major concern of memory-related. Most of the time my RAM usage is greater than 98% which makes us difficult to implement something new. Since we are in restrained memory environment, I was curious to know if somehow we can use the part of FLASH memory as the RAM. 

As per datasheet - https://www.ti.com/lit/ds/symlink/tm4c129encpdt.pdf?ts=1624026622136&ref_url=https%253A%252F%252Fwww.google.com%252F

Table 2-5, we can use FLASH as the data section too. 

I was trying this into tm4c129encpdt.cmd file-


SECTIONS
{
.intvecs: > 0x00000000
.text : > FLASH
.const : > FLASH
.cinit : > FLASH
.pinit : > FLASH
.init_array : > FLASH
 .data : > FLASH

.vtable : > SRAM
//.data : > SRAM

.bss : > SRAM
.sysmem : > SRAM
.stack : > SRAM
}

__STACK_TOP = __stack + 512;

If you see, I am trying to put the .data section into flash but it is not working. Even my code is not executing. I know RAM and FLASH are totally different but is there any way to use them this way?

Thanks

AkhiG

  • Hi,

      You cannot use flash to replace RAM. The flash is a non-volatile memory. You cannot just write to it like writing a RAM. A change of value from 0 to 1 requires a erase to the flash. I will suggest you use the on-chip Emulated EEprom instead. There is 6kB of EEprom on chip. Please bear in mind the number of program/erase cycle the EEprom can support. It is spec'ed in the datasheet.

    uint32_t ui32EEPROMInit;
    uint32_t pui32Data[2];
    uint32_t pui32Read[2];
    //
    // Enable the EEPROM module.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_EEPROM0);
    //
    // Wait for the EEPROM module to be ready.
    //
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_EEPROM0))
    {
    }
    //
    // Wait for the EEPROM Initialization to complete
    //
    ui32EEPROMInit = EEPROMInit();
    //
    // Check if the EEPROM Initialization returned an error
    // and inform the application
    //
    if(ui32EEPROMInit != EEPROM_INIT_OK)
    {
    while(1)
    {
    }
    }
    //
    // Program some data into the EEPROM at address 0x400.
    //
    pui32Data[0] = 0x12345678;
    pui32Data[1] = 0x56789abc;
    EEPROMProgram(pui32Data, 0x400, sizeof(pui32Data));
    //
    // Read it back.
    //
    EEPROMRead(pui32Read, 0x400, sizeof(pui32Read));