PSoC5: Running Code out of RAM using the GCC compiler
Question: How can I place code and interrupt handlers in RAM using the GCC compiler?
Answer: Gcc supports the use of the __attribute__ keyword which allows you to apply special attributes to your code. The “section” attribute places code in a specific memory section as defined in the cm3gcc.ld file. RAM is defined as the “.data” section. So, for example, if you wanted to place a function in RAM the code for the function prototype would look like this: void foo (void) __attribute__ ((section(“.data”))); This method can be used for variables as well. A great use of this feature is to place interrupt handlers in RAM for faster execution time. If you define your own ISRs you can do this by placing __attribute__ ((section “.data”))) after the ISR prototype like a normal function declaration. The other option is to use the Cypress generated ISR code that comes with an ISR component. You can add a declaration statement to the section of code provided for the user to include modules and declare variables. Here is an example: // place interrupt in SRAM to improve speed extern CY_ISR_PROTO(isr_1_Interrupt) __attribute__ ((section(".data"))); For an isr named isr_1.