Hi Adam,
I also experienced the same problem as yours when I developed my project.
In the past when I use KDS, I use KEEP command in ld file to avoid variable being optimized.
MCUXpresso uses manage linker script, if we modify ld file by hand, we will loose the convenience of "manage linker script".
To avoid optimizing global variable, sometimes I wrote dummy code. For example, to avoid g_var being optimized:
int g_var;
main(){
volatile int dummy=0;
dummy=g_var;
...
}
Have a great day,
Jennie Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------