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.
I am trying to define global variables for a simple PWM code but for some reason, CCS does NOT recognize the "Frequency" and "DutyCycle" variables as global. I have attached my code below. Are you able to determine what is going on?
Thank you,
Andrew
What do you mean with "does not recognize"? What specific problem are you seeing?
(It's likely that these variables got optimized away because they never change.)
Yes, this is what happens when they got optimized away.
The compiler knows that these variables never get changed by your code.
If you want to modify them in ways that the compiler does not know about, declare them as volatile.
Okay, volatile is a bad idea.
Instead let's pretend to actually change these variables:
if (WDTCTL == 0) { /* never actually happens */ Frequency = 0; DutyCycle = 0; }
Andrew Butler said:I believe CCS thinks those two variables are local because when I try to vary them in the expression window of the debug session, it says "Error: Could not read 0x200: Execution state prevented access".
Are you trying to modify those globals while the program is actually running (as opposed to when it's paused in the debugger)?
Yes, I am trying to modify those variables while the program is running because I have been able to do it before. However, my real goal is to attach a GUI to this program and it won't work because it is not recognizing those variables as global.
Do you plan to establish a connection to the PC where something is running that modifies the PWM of the micro?
This no problem - the micro can change those variables during runtime, of course.
But the debugger cannot.
When using a GUI on the PC, some kind of RS232-UART (MAX232) or USB-UART bridge (FT232) is common. But this variable can be changed from several sources like input buttons, encoders or any other user-interface to act with the running program.
**Attention** This is a public forum