Forums

Help,please. very strange code problem on ADSP TS101s DSP

Started by Paul October 27, 2006
hi, there,

I met a very strange problem when running my code on ADSP  TS101 EZ
Lite kit.

The program can run well without any problem if i run the program in
debug mode step by step.

But I just click "run" command to run the program without any
breakpoint, one of the varibale in my program can not get the corrent
value.  This is a local varible, it reads the value from one global
varible.

Can anybody give me some suggestions?

thanks.

paul


Paul wrote:

> hi, there, > > I met a very strange problem when running my code on ADSP TS101 EZ > Lite kit. > > The program can run well without any problem if i run the program in > debug mode step by step. > > But I just click "run" command to run the program without any > breakpoint, one of the varibale in my program can not get the corrent > value. This is a local varible, it reads the value from one global > varible. > > Can anybody give me some suggestions?
Do you know the keyword "volatile" ? Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
Thanks Vladimir .Actually, I have tried set the local variable as
volatile type, but this does not work.

Can anybody explain me how this error occured?

thanks.
Vladimir Vassilevsky wrote:
> Paul wrote: > > > hi, there, > > > > I met a very strange problem when running my code on ADSP TS101 EZ > > Lite kit. > > > > The program can run well without any problem if i run the program in > > debug mode step by step. > > > > But I just click "run" command to run the program without any > > breakpoint, one of the varibale in my program can not get the corrent > > value. This is a local varible, it reads the value from one global > > varible. > > > > Can anybody give me some suggestions? > > Do you know the keyword "volatile" ? > > Vladimir Vassilevsky > > DSP and Mixed Signal Design Consultant > > http://www.abvolt.com

Paul wrote:

> Thanks Vladimir .Actually, I have tried set the local variable as > volatile type, but this does not work.
???? It is the global variable that probably has to be declared as the volatile. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
> > Can anybody explain me how this error occured? > > thanks. > Vladimir Vassilevsky wrote: > >>Paul wrote: >> >> >>>hi, there, >>> >>>I met a very strange problem when running my code on ADSP TS101 EZ >>>Lite kit. >>> >>>The program can run well without any problem if i run the program in >>>debug mode step by step. >>> >>>But I just click "run" command to run the program without any >>>breakpoint, one of the varibale in my program can not get the corrent >>>value. This is a local varible, it reads the value from one global >>>varible. >>> >>>Can anybody give me some suggestions? >> >>Do you know the keyword "volatile" ? >> >>Vladimir Vassilevsky >> >>DSP and Mixed Signal Design Consultant >> >>http://www.abvolt.com > >
Sorry, I made a mistake, I do declare the global variabl as volatile
already when it is first declared.

thanks.

Vladimir Vassilevsky wrote:
> Paul wrote: > > > Thanks Vladimir .Actually, I have tried set the local variable as > > volatile type, but this does not work. > > ???? > > It is the global variable that probably has to be declared as the volatile. > > > Vladimir Vassilevsky > > DSP and Mixed Signal Design Consultant > > http://www.abvolt.com > > > > > > Can anybody explain me how this error occured? > > > > thanks. > > Vladimir Vassilevsky wrote: > > > >>Paul wrote: > >> > >> > >>>hi, there, > >>> > >>>I met a very strange problem when running my code on ADSP TS101 EZ > >>>Lite kit. > >>> > >>>The program can run well without any problem if i run the program in > >>>debug mode step by step. > >>> > >>>But I just click "run" command to run the program without any > >>>breakpoint, one of the varibale in my program can not get the corrent > >>>value. This is a local varible, it reads the value from one global > >>>varible. > >>> > >>>Can anybody give me some suggestions? > >> > >>Do you know the keyword "volatile" ? > >> > >>Vladimir Vassilevsky > >> > >>DSP and Mixed Signal Design Consultant > >> > >>http://www.abvolt.com > > > >
Paul wrote:
> hi, there, > > I met a very strange problem when running my code on ADSP TS101 EZ > Lite kit. > > The program can run well without any problem if i run the program in > debug mode step by step. > > But I just click "run" command to run the program without any > breakpoint, one of the varibale in my program can not get the corrent > value. This is a local varible, it reads the value from one global > varible. > > Can anybody give me some suggestions? > > thanks. > > paul >
I normally disassemble the program to sort out these sorts of problems. The optimizer might be playing tricks on you. John
Can you clarify if it the exact same executable you run step by step or full 
out?

If it is, the optimizer won't be the problem.  If, however, you run an 
executable built in debug mode versus one built in release mode it certainly 
could be.

I recall seeing similar problems before and am scratching my head as to what 
it turned out to be.  It is most likely a problem in your real code that 
single stepping through is hiding.

How and where is your global variable changed, and how and were does the 
local variable try to access it?  And how do you know it doesn't get the 
right value?

----
Ron Huizen
BittWare

"John Sampson" <johns@3db-labs.com> wrote in message 
news:e6s1h.20563$OE1.12317@tornado.ohiordc.rr.com...
> Paul wrote: >> hi, there, >> >> I met a very strange problem when running my code on ADSP TS101 EZ >> Lite kit. >> >> The program can run well without any problem if i run the program in >> debug mode step by step. >> >> But I just click "run" command to run the program without any >> breakpoint, one of the varibale in my program can not get the corrent >> value. This is a local varible, it reads the value from one global >> varible. >> >> Can anybody give me some suggestions? >> >> thanks. >> >> paul >> > > I normally disassemble the program to sort out these sorts of problems. > The optimizer might be playing tricks on you. > > John
Yes. they are the same executable file, both are in debug mode.
The globle variable is updated by DMA from external to internal and
there is no proble for the global variables.

The local variable update himself like this: WorkLine_ID0[N] is the
global varible and sum is the local varibale, the relationship is like
this:

SDRAM_to_Internal_DMA(&shared_data[j*N],WorkLine_ID0); //update
global					sum=WorkLine_ID0[0]; //update local varibale.
sum=sum/RefLine_ID0[k];

if we run the program step by step in debug mode, in the debug
windows->expressions, we can watch the value of "sum" and it will get
correct value.

if we set a breakpoint at sum=sum/RefLine_ID0[k]; and then watch the
value of sum, it will get the wrong value, and then we step forward,
the "sum=sum/RefLine_ID0[k];" also give us a wrong value,and
RefLine_ID0[k] still hold the correct value, which means sum hold a
wrong value.

This is very wired.

paul.






Ron Huizen wrote:
> Can you clarify if it the exact same executable you run step by step or full > out? > > If it is, the optimizer won't be the problem. If, however, you run an > executable built in debug mode versus one built in release mode it certainly > could be. > > I recall seeing similar problems before and am scratching my head as to what > it turned out to be. It is most likely a problem in your real code that > single stepping through is hiding. > > How and where is your global variable changed, and how and were does the > local variable try to access it? And how do you know it doesn't get the > right value? > > ---- > Ron Huizen > BittWare > > "John Sampson" <johns@3db-labs.com> wrote in message > news:e6s1h.20563$OE1.12317@tornado.ohiordc.rr.com... > > Paul wrote: > >> hi, there, > >> > >> I met a very strange problem when running my code on ADSP TS101 EZ > >> Lite kit. > >> > >> The program can run well without any problem if i run the program in > >> debug mode step by step. > >> > >> But I just click "run" command to run the program without any > >> breakpoint, one of the varibale in my program can not get the corrent > >> value. This is a local varible, it reads the value from one global > >> varible. > >> > >> Can anybody give me some suggestions? > >> > >> thanks. > >> > >> paul > >> > > > > I normally disassemble the program to sort out these sorts of problems. > > The optimizer might be playing tricks on you. > > > > John
Does your DMA routine wait for the DMA to complete.  If it does not, then 
when you're single stepping, the DMA probably gets to run enough before the 
"sum" assignment due to how slow you're stepping.  When running past the 
assignment, the DMA hasn't had a chance to do its work yet before the 
assignment.

In the debugger you can tell it whether IOs (like DMAs) can keep running in 
the background while you're halted, or if they halt as well.

"Paul" <paul.pettus@gmail.com> wrote in message 
news:1162489910.214188.204430@f16g2000cwb.googlegroups.com...
> Yes. they are the same executable file, both are in debug mode. > The globle variable is updated by DMA from external to internal and > there is no proble for the global variables. > > The local variable update himself like this: WorkLine_ID0[N] is the > global varible and sum is the local varibale, the relationship is like > this: > > SDRAM_to_Internal_DMA(&shared_data[j*N],WorkLine_ID0); //update > global sum=WorkLine_ID0[0]; //update local varibale. > sum=sum/RefLine_ID0[k]; > > if we run the program step by step in debug mode, in the debug > windows->expressions, we can watch the value of "sum" and it will get > correct value. > > if we set a breakpoint at sum=sum/RefLine_ID0[k]; and then watch the > value of sum, it will get the wrong value, and then we step forward, > the "sum=sum/RefLine_ID0[k];" also give us a wrong value,and > RefLine_ID0[k] still hold the correct value, which means sum hold a > wrong value. > > This is very wired. > > paul. > > > > > > > Ron Huizen wrote: >> Can you clarify if it the exact same executable you run step by step or >> full >> out? >> >> If it is, the optimizer won't be the problem. If, however, you run an >> executable built in debug mode versus one built in release mode it >> certainly >> could be. >> >> I recall seeing similar problems before and am scratching my head as to >> what >> it turned out to be. It is most likely a problem in your real code that >> single stepping through is hiding. >> >> How and where is your global variable changed, and how and were does the >> local variable try to access it? And how do you know it doesn't get the >> right value? >> >> ---- >> Ron Huizen >> BittWare >> >> "John Sampson" <johns@3db-labs.com> wrote in message >> news:e6s1h.20563$OE1.12317@tornado.ohiordc.rr.com... >> > Paul wrote: >> >> hi, there, >> >> >> >> I met a very strange problem when running my code on ADSP TS101 EZ >> >> Lite kit. >> >> >> >> The program can run well without any problem if i run the program in >> >> debug mode step by step. >> >> >> >> But I just click "run" command to run the program without any >> >> breakpoint, one of the varibale in my program can not get the corrent >> >> value. This is a local varible, it reads the value from one global >> >> varible. >> >> >> >> Can anybody give me some suggestions? >> >> >> >> thanks. >> >> >> >> paul >> >> >> > >> > I normally disassemble the program to sort out these sorts of problems. >> > The optimizer might be playing tricks on you. >> > >> > John >
I understand what you said. Maybe I should add a justment to see if the
DMA finished or not, then continure the local varible assigment.

How to tell if the DMA keep running in the background or not?

I only check the DMA status register to see if the DMA finished
correctly or not. But I can only check the register when I pause the
program.

thanks.

Ron Huizen wrote:
> Does your DMA routine wait for the DMA to complete. If it does not, then > when you're single stepping, the DMA probably gets to run enough before the > "sum" assignment due to how slow you're stepping. When running past the > assignment, the DMA hasn't had a chance to do its work yet before the > assignment. > > In the debugger you can tell it whether IOs (like DMAs) can keep running in > the background while you're halted, or if they halt as well. > > "Paul" <paul.pettus@gmail.com> wrote in message > news:1162489910.214188.204430@f16g2000cwb.googlegroups.com... > > Yes. they are the same executable file, both are in debug mode. > > The globle variable is updated by DMA from external to internal and > > there is no proble for the global variables. > > > > The local variable update himself like this: WorkLine_ID0[N] is the > > global varible and sum is the local varibale, the relationship is like > > this: > > > > SDRAM_to_Internal_DMA(&shared_data[j*N],WorkLine_ID0); //update > > global sum=WorkLine_ID0[0]; //update local varibale. > > sum=sum/RefLine_ID0[k]; > > > > if we run the program step by step in debug mode, in the debug > > windows->expressions, we can watch the value of "sum" and it will get > > correct value. > > > > if we set a breakpoint at sum=sum/RefLine_ID0[k]; and then watch the > > value of sum, it will get the wrong value, and then we step forward, > > the "sum=sum/RefLine_ID0[k];" also give us a wrong value,and > > RefLine_ID0[k] still hold the correct value, which means sum hold a > > wrong value. > > > > This is very wired. > > > > paul. > > > > > > > > > > > > > > Ron Huizen wrote: > >> Can you clarify if it the exact same executable you run step by step or > >> full > >> out? > >> > >> If it is, the optimizer won't be the problem. If, however, you run an > >> executable built in debug mode versus one built in release mode it > >> certainly > >> could be. > >> > >> I recall seeing similar problems before and am scratching my head as to > >> what > >> it turned out to be. It is most likely a problem in your real code that > >> single stepping through is hiding. > >> > >> How and where is your global variable changed, and how and were does the > >> local variable try to access it? And how do you know it doesn't get the > >> right value? > >> > >> ---- > >> Ron Huizen > >> BittWare > >> > >> "John Sampson" <johns@3db-labs.com> wrote in message > >> news:e6s1h.20563$OE1.12317@tornado.ohiordc.rr.com... > >> > Paul wrote: > >> >> hi, there, > >> >> > >> >> I met a very strange problem when running my code on ADSP TS101 EZ > >> >> Lite kit. > >> >> > >> >> The program can run well without any problem if i run the program in > >> >> debug mode step by step. > >> >> > >> >> But I just click "run" command to run the program without any > >> >> breakpoint, one of the varibale in my program can not get the corrent > >> >> value. This is a local varible, it reads the value from one global > >> >> varible. > >> >> > >> >> Can anybody give me some suggestions? > >> >> > >> >> thanks. > >> >> > >> >> paul > >> >> > >> > > >> > I normally disassemble the program to sort out these sorts of problems. > >> > The optimizer might be playing tricks on you. > >> > > >> > John > >