The tickers in ISR stops counting in CodeWarrior V4.6 with USB-ML-12?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

The tickers in ISR stops counting in CodeWarrior V4.6 with USB-ML-12?

Jump to solution
2,546 Views
Pang
Contributor I
Hi everyone,
 
It is strange that, in True-time Simulator and Real-time debugger, when step in, the tickers in my ISR appear that they stop counting.
 
++Tick_60HZ;
 
it won't change after ++ operation, even if I do not disable INT in communication settings.
 
What went wrong?
 
Thanks,
 
Pang
Labels (1)
Tags (1)
0 Kudos
1 Solution
739 Views
CrasyCat
Specialist III
Hi
 
Do you mean that you have an instruction ++Tick in an interrupt function and that the Tick counter is not incremented when you step in on that instruction?
 
That is strange.
Is the compiler generating code for the instruction?
If you select Source -> Mark is there a red mark in front of the instruction?
What is the assembly code generated for that C instruction (You should be able to see it in the assembly window.
 
CrasyCat

View solution in original post

0 Kudos
7 Replies
740 Views
CrasyCat
Specialist III
Hi
 
Do you mean that you have an instruction ++Tick in an interrupt function and that the Tick counter is not incremented when you step in on that instruction?
 
That is strange.
Is the compiler generating code for the instruction?
If you select Source -> Mark is there a red mark in front of the instruction?
What is the assembly code generated for that C instruction (You should be able to see it in the assembly window.
 
CrasyCat
0 Kudos
739 Views
Pang
Contributor I
You're right. Just the assembly block and Registers.  The values there are correct. It appears that the change of these values is not updated on data window. Is there something I missed in True-Time Simulator.
 
Thanks,
 
Pang
 
 
0 Kudos
739 Views
CrasyCat
Specialist III
Hello
 
Is the variable Tick a local or global variable?
If it is local, the compiler may decide to keep it in a register as the variable will not exist any more outside of the function.
 
You have to define the variable as global or volatile to force the compiler to update its value in memory.
 
I would need to see the whole code of the function as well as the variable definition/declaration to be able to help more.
 
CrasyCat
0 Kudos
739 Views
Pang
Contributor I
Here is pseudo code:
 
void interrupt Irq_ISR(void)  // 1/60 second
{
 static char x2 = 0; 
   ++x2;
}
 
The debugger could not update x2 every 1/60 second. After I changed it to volatile, it works.
 
As you mentioned, we have to defince the global or volatile variable for automatic update. Am I right?
 
Thanks,
 
Pang 
0 Kudos
739 Views
CrasyCat
Specialist III
Hello
 
Well in that case, the compiler is in fact incrementing the counter in memory (at least on a small program I wrote to reproduce the issue).
The problem here is that you define x2 as local static variable.
Scope for a local static variable is the function where it is defined. That means you will not be able to see the variable value when you are outside of the function where it is defined.
 
If you want o be able to see how the variable is modified, while the code is running you have to define it as global (not static local).
 
CrasyCat
0 Kudos
739 Views
Pang
Contributor I
It is strange that the values of my global variables still stay unchanged. I can change the value in the registers, but I could not see or make any changes in Data window for global variables.
 
Any idea about settings or something missed?
 
Thanks,
 
Pang
0 Kudos
739 Views
CrasyCat
Specialist III
Hello
 
Are you looking at eh value of the variable while the application is stopped or while it is running?
If you are looking at value when application is stopped, value of global variable must be updated.
If this is not happening, you need to submit a service request  for that.
 
To log the issue with Freescale please go to following URL:
    http://www.freescale.com/webapp/sps/site/homepage.jsp?nodeId=054670&tid=FSH
and click on "Submit a service request"
Make sure to attach a reproducible case to demonstrate what is going wrong. You can use Help -> Pack and Go and let hte wizard extract the necessary information for the service request.
 
If you want to see variable changing while the application is running, you need to activate periodical refresh for the global data window.
 
Just click right on the global data window, select Mode -> Periodical and adjust the refresh period.
 
CrasyCat
0 Kudos