Jump to content
Sign in to follow this  
rice

benefits of #pragam CODE_SECTION()

Recommended Posts

i come across a piece of code that puts every ISR code after #pragma CODE_SECTION("somewhere"). Is there any benefit from doing so? optimization?

 

This is under TI CCS, by the way.

 

will appreciate your feedback.

Share this post


Link to post
Share on other sites

This tells the compiler to put the code following that #pragma into a specific section, which influences the location in memory where the linker will put it. See 5.10.4 in MSP430 Optimizing C/C++ Compiler User's Guide.

http://www.ti.com/litv/pdf/slau132g

 

Looking at the lnk*.cmd files in the project folder and *.map in the debug or release directory of the project might shed some more light on what's happening.

 

What's "somewhere" in your example?

Share this post


Link to post
Share on other sites

i come across a piece of code that puts every ISR code after #pragma CODE_SECTION("somewhere"). Is there any benefit from doing so? optimization?

 

This is under TI CCS, by the way.

Although I haven't used that under CCS myself, the MSP430 architecture requires that ISR code be placed in the low 64 KiB of memory, because the interrupt vector table uses 16-bit words to store the address of the handler. The pragma is probably being used to make sure the ISR isn't placed in high memory, causing a linker failure, when compiling for other memory models.

 

The feature would only be relevant for code that was written with CPUX/20-bit MCUs in mind, which is why it's unlikely to be in any smaller or older examples from TI.

Share this post


Link to post
Share on other sites

thank you, pabigot!

this would be true for all chips of 64kb or more, mine happens to be 128kb. most if not all samples are based on 16kb chip.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×