Technical discussions about the TI C28x DSPs (including the C2810, C2811, C2812, F2801, F2806, F2808, F2810,, F2811, F2812, R2811 and R2812).
HI,
I found a very strange problem. MY code as following. Running in debug mode, I found even
variable A become more than 50(by watch window), the code is still running in the while loop,
and can not run to the code after while loop.
Anybody can help me, I am mad already.
unsigned int A;//global variable
void main(void)
{
while(A<50)
{
}
//other code here
}
interrupt void XInt2_ISR(void)//a external interrupt
{
A++:
}
------------------------------------
OMAP35x EVM jump-starts low-power apps
------------------------------------
The modular and extensible OMAP35x Evaluation Module (EVM) enables developers to start building
applications based on the OMAP35x architecture:http://www.DSPRelated.com/omap35x
You can post a message or access and search the archives of this group on DSPRelated.com:
http://www.dsprelated.com/groups/c28x/1.php
_____________________________________
HI
=20
I think it is a optimiser reason of the compiler.
The keyword volatile tells to the compiler that a higher instance (in
your case the interrupt service routine) can change the value of A. If
you do not use this keyword volatile then the optimiser tries to make
shorter the code.
try
volatile unsigned int A;
=20
Please check the asm file output of your compiler, then you can see what
happen.
=20
Best rergards
=20
Franz
=20
=20
-----Urspr=FCngliche Nachricht-----
Von: c...@yahoogroups.com [mailto:c...@yahoogroups.com] Im Auftrag von
b...@meidensg.com.sg
Gesendet: Montag, 9. Juni 2008 09:57
An: c...@yahoogroups.com
Betreff: [c28x] A very strange problem
=20
HI,
I found a very strange problem. MY code as following. Running in debug
mode, I found even variable A become more than 50(by watch window), the
code is still running in the while loop, and can not run to the code
after while loop.=20
Anybody can help me, I am mad already.
unsigned int A;//global variable
void main(void)
{
while(A<50)
{
}
//other code here
}
interrupt void XInt2_ISR(void)//a external interrupt=20
{
A++:
}
=20
------------------------------------
OMAP35x EVM jump-starts low-power apps
------------------------------------
The modular and extensible OMAP35x Evaluation Module (EVM) enables develope=
rs to start building applications based on the OMAP35x architecture: http:/=
/www.DSPRelated.com/omap35x
You can post a message or access and search the archives of this group on D=
SPRelated.com:
http://www.dsprelated.com/groups/c28x/1.php
_____________________________________
In your case, you must specify A as a volatile variable.
Why ? Because the optimizer will not see A variable changing in the main=20
source code.
It doesn't know that the varaible will be change outside ... so it must=20
re-read in each loop the variable A.
so, the fix is :=20
volatile unsigned int A;//global variable
have a look to the generated assembly code if you have a doubt !
=20
Veuillez r=E9pondre =E0 b...@meidensg.com.sg
Envoy=E9 par : c...@yahoogroups.com
Pour : c...@yahoogroups.com
cc :=20=20=20=20=20
Objet : [c28x] A very strange problem
HI,
I found a very strange problem. MY code as following. Running in debug=20
mode, I found even variable A become more than 50(by watch window), the=20
code is still running in the while loop, and can not run to the code after=
=20
while loop.=20
Anybody can help me, I am mad already.
unsigned int A;//global variable
void main(void)
{
while(A<50)
{
}
=20
//other code here
}
interrupt void XInt2_ISR(void)//a external interrupt=20
{
A++:
}
------------------------------------
OMAP35x EVM jump-starts low-power apps
------------------------------------
The modular and extensible OMAP35x Evaluation Module (EVM) enables develope=
rs to start building applications based on the OMAP35x architecture: http:/=
/www.DSPRelated.com/omap35x
You can post a message or access and search the archives of this group on D=
SPRelated.com:
http://www.dsprelated.com/groups/c28x/1.php
_____________________________________