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/CC1310: Task Stack in GPRAM Problem

Part Number: CC1310

Tool/software: TI-RTOS

Hi all,

I have data transmission on UART and radio. When I move task stack of Uart read task to GPRAM, data cannot be read from UART. Are there any restrictions about GPRAM (is it not like a SRAM?)?

I move the stack with the following code.

#define FLASH_BASE              0x0
#define FLASH_SIZE              0x20000
#define RAM_BASE                0x20000000
#define RAM_SIZE                0x5000
#define GPRAM_BASE              0x11000000
#define GPRAM_SIZE              0x2000



/* System memory map */

MEMORY
{
    /* Application stored in and executes from internal flash */
    FLASH (RX) : origin = FLASH_BASE, length = FLASH_SIZE
    /* Application uses internal RAM for data */
    SRAM (RWX) : origin = RAM_BASE, length = RAM_SIZE

    GPRAM (RWX) : origin = GPRAM_BASE, length = GPRAM_SIZE
}

/* Section allocation in memory */

SECTIONS
{
    .text           :   > FLASH
    .binit	        :   > FLASH
    .const          :   > FLASH
    .constdata      :   > FLASH
    .rodata         :   > FLASH
    .cinit          :   > FLASH
    .pinit          :   > FLASH
    .init_array     :   > FLASH
    .emb_text       :   > FLASH
    .ccfg           :   > FLASH (HIGH)

    .data           :   > SRAM
    .gpram 			:   > GPRAM
    {
    tsch.obj(*freqTable)// this is static array
    uartTask.obj(*interTaskStack)	// task stack of Uart read task
    uartTask.obj(*mailboxBuffer)
    }
    .bss            :   > SRAM
    .sysmem         :   > SRAM
    .stack          :   > SRAM (HIGH)
    .nonretenvar    :   > SRAM
#ifdef __TI_COMPILER_VERSION__
#if __TI_COMPILER_VERSION__ >= 15009000
/*  Hide section from older compilers not supporting the "ramfunc" attribute.
    See processors.wiki.ti.com/.../Placing_functions_in_RAM */
    .TI.ramfunc : {} load=FLASH, run=SRAM, table(BINIT)
#endif
#endif
}

What can be the problem about GPRAM and task stacks?

Regards.

Ramazan

  • Hi,

    it behaves like an SRAM if you disable the instruction cache in the ccfg.c file:

    #define SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_GPRAM        0x0        // Cache is disabled and GPRAM is available at 0x11000000-0x11001FFF

    Please note that this will slow down your device significantly and increase power consumption. If you are running out of RAM, I suggest to reduce the amount of tasks or reduce the stack sizes based on execution analysis. Use the real-time object viewer ROV in Code Composer Studio to determine the maximum stack size of each tasks during execution.

    But given the small RAM of the CC13x0, it would be better to operate on a single task and build an event-driven system using the Event module in the TI-RTOS kernel. At least that's my observation.

  • Hi Richard,

    My CCFG.c config  is;

    //#####################################
    // Select between cache or GPRAM
    //#####################################
    #ifndef SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_GPRAM
    #define SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_GPRAM        0x0        // Cache is disabled and GPRAM is available at 0x11000000-0x11001FFF
    //#define SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_GPRAM           0x1        // Cache is enabled and GPRAM is disabled (unavailable)
    #endif

    So i enabled GPRAM. I am getting so much data from UART may be GPRAM is slow to handle it ? Because of slowness can not handle UART task properly. Can it be like that?

    I thought about your suggestion about Event module. But i cannot understand how can a single task handle so many jobs? I have the jobs of RX from RF, TX RF, RX UART, TX UART, a timing task that keeps synchronized OS timer and RF timer and i have one task that make some calculations with the data coming from UART. So, how can i handle it with single task with Event module ? Can you give some examples or explain with some details ?

    Thank you, regards.

    Ramazan

  • Hi Richard,

    GPRAM worked with current configurations. I guess i had another issue and i thought it is related to GPRAM. Thus, it is OK now.
    But if you can explain about Event module with single task, i will be appreciated.

    Regards.
    Ramazan
  • Nice to hear.

    With the Event module, you would split your application into short-running, non-blocking actions. All driver calls need to be non-blocking and use callbacks. In the callbacks, you would perform urgent work and post an event to the event handler loop for follow-up work. Those actions would not be able to interrupt each other. A central event handler loop in the task would handle events as they occur and prioritize between events. You could even combine that with a state machine if you want, but you don't need to. This post shows an example, but you could do it simpler.

    The Event module in TI-RTOS can only distinguish between 32 different events because they are stored in a bit mask. To support more events, you would have to create an event queue or implement your own Event module with a larger bitmask. Event driven system like QP and Contiki work that way and are very efficient on memory-constrained devices.

    But I don't have the time to go too much into detail here. Event-driven vs. thread-based design is a religious war. Each of them has pros and cons. I am just saying that an event-driven design allows you to operate on a single-stack and fits very well on devices with little RAM like the CC13xx.

  • Hi Richard,

    Thank you for your advise. I will try event based implementation on my afterward projects.

    Best regards.
    Ramazan