How to execute programs in SRAM PSoC6

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
user_3856526
Level 1
Level 1

The datasheet of PSoC6 describes that it is possible to execute code from the code and the sram regions.

Are there any code examples available for executing a whole program in the SRAM?

Many thanks,

Nadja

0 Likes
1 Solution

I realized that the my previous post might be misleading. Actually you can not use PSoC Creator/Programmer to program SRAM, because the tools are a command cluster manipulating inside flash.

The feasible way for you might be to conduct a copy of code from flash to sram after each time power on.

View solution in original post

0 Likes
4 Replies
ShipingW_81
Moderator
Moderator
Moderator
500 replies posted 250 solutions authored 250 replies posted

If you want to put whole program in SRAM, put the sections originally defined in flash to ram by modifying the linker file for each core, just like below section .text:

.text :

    {

        . = ALIGN(4);

        __Vectors = . ;

        KEEP(*(.vectors))

        . = ALIGN(4);

        __Vectors_End = .;

        __Vectors_Size = __Vectors_End - __Vectors;

        __end__ = .;

        . = ALIGN(4);

        *(.text*)

        KEEP(*(.init))

        KEEP(*(.fini))

        /* .ctors */

        *crtbegin.o(.ctors)

        *crtbegin?.o(.ctors)

        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)

        *(SORT(.ctors.*))

        *(.ctors)

        /* .dtors */

        *crtbegin.o(.dtors)

        *crtbegin?.o(.dtors)

        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)

        *(SORT(.dtors.*))

        *(.dtors)

        /* Read-only code (constants). */

        *(.rodata .rodata.* .constdata .constdata.* .conststring .conststring.*)

        KEEP(*(.eh_frame*))

    } > flash  ->  ram

If you just want to put single function in SRAM, you can refer to the method mentioned in the following artical for P5 - Running code in RAM using PSoC5 and the GCC compiler

0 Likes

Thanks for your answer.

I tried this with the Dual Core Blinky Example in PSoc Creator with the PSoC 6 BLE Poineer Kit. In both linkerfiles (cy8c6xx7_cm0plus.ld and cy8c6xx7_cm4.ld) I replaced every "} > flash" with "} > ram".

I can build the software, but after programming it is not running on the device. Do I need to do something else?

0 Likes

I realized that the my previous post might be misleading. Actually you can not use PSoC Creator/Programmer to program SRAM, because the tools are a command cluster manipulating inside flash.

The feasible way for you might be to conduct a copy of code from flash to sram after each time power on.

0 Likes

Thank you very much, this is the right way for me!

0 Likes