DSPRelated.com
Forums

memory management problem in C5416

Started by megha daga April 23, 2006
Hi
I wrote the mail about the memory management problem I am facing. I told in my previous mail that I run my prog on simulator and it ran to a random addr and gave an error of
Trouble Running Target CPU.
I ran the code on the device and I am getting an error message as:
cant remove breakpoint at 32E0.
32E0 is the addr from where main() starts. Someone kindly help me regarding this error, what it means and how it can be removed. I think it is related to the memory management. But I am not getting how. I am reattaching the code. Its in abc format kindly convert it to .zip extension. Kindly have a look and help me out.
Kindly help
Thanks
Megha
Ritesh Patel wrote: I believe you may change
if((fileid = fopen( "8chF.txt", "r" )) == NULL )
printf( "The file 'test' was not opened\n" );
to

if((fileid = fopen( "8chF.txt", "r" )) == NULL )
{
printf( "The file 'test' was not opened\n" );
exit(0);
}

You must ensure that File is being opened properly. You can also print "fileid"
Also you can use break points.... put 3-4 break points in different parts of program and you can varify expected program flow.

If file is getting opened and still problem persists then, try below

add system(asm " nop "); // please find proper format if it is wrong.
add above lines couple of times so that there be some delay between opening file and using that fileid. This may be a problem sometimes. due to pipelining.

One more thing
if(fgets(temp, 250, fileid) == NULL)
{
exit(1);
}
You may replace "exit(1)" with other thing (just look at help of continue and break or goto etc... generaly you should avoid such statements) which jumps to DOAGCDRC. Otherwise I think (If I am right) your program will never reach to DOAGCDRC after numchan and rather it will come out of program execution.

But, I tell you I am not confident about using file operations in CCS.
If this does not solve your problem then, you may post it to 54x group. As I told earlier if you can send your project with directory which others can test in their system then, it would be nice.

Ritesh

On 4/21/06, megha daga wrote: Thanks Ritesh
Actually I thought may be the error is cause till now I was working on simulator and it will go if i work on the device. But when I started working on the device, I faced a strange error:
I have the code like:
if((fileid = fopen( "8chF.txt", "r" )) == NULL )
printf( "The file 'test' was not opened\n" );

//Read in the number of channels
while(1)
{
if(fgets(temp, 250, fileid) == NULL)
{
exit(1);
}

sscanf(temp, "%s", &temp);
if(!strcmp(temp,"NUMCHAN"))
{
fgets(temp, 250, fileid);
sscanf(temp, "%hu", &numchan);
break;
}

}

//Read in whether or not to do agcdrc
while(1)
{
if(fgets(temp, 250, fileid) == NULL)
{
exit(1);
}

sscanf(temp, "%s", &temp);
if(!strcmp(temp,"DOAGCDRC"))
{
fgets(temp, 250, fileid);
sscanf(temp, "%hu", &doagcdrc);
rewind(fileid);
break;
}
}
In this I am doing debugging and going step by step. So when I do step after fopen my PC goes to doagcdrc for loop instead of numchan for loop. I dont understand why its doing that. That part was working fine on simulator. I even checked the assembly view. In that too my fopen () is ending at 4157 and the for loop (for numcahn) starts at 4159.
Kindly give some idea.
Thanks a lot

megha

Ritesh Patel < r...@gmail.com> wrote: Hi megha,
You can first browse all menu on CCS. I think in View menu you may see displaying registers. where PC and SP will be displayed. YES These stores address only. what you can do is that when you compile and load (in simulator or any) the program see start point of program counter address(PC). You can see by menu View -> mixed mode (or assembaly). now execute using single step and debug. there will be an instruction call __c_main (something like this where main word is written). This is the place where your C main function will be called. When you single step from your starting address and till this line you will see so many of registers like SP and other so many will be set here. then you enter main function. see your iterations running normally as per expectation. when you enter a function your SP will change and when you return from it, it must be what it was. check these things. this will tell you if your normal program flow is not going well. dont just go for 32000
iterations rather run some iterations with single step. also varify counter "i" is increasing by one everytime or after sometime it jumps to some junk value (like 19000 you specified)

About your program error. Any error should be avoided. You can run program with warnings (better you remove that also) but, should not go ahead with any error. was there any error in loading program in simulator. if it was you can not run program

I dont have any idea about RTDX feature of CCS. Do you really need it?? If you just want to check your program's proper working (mathematically) then, use file input and file output. when it runs properly in simulator then go to emulator and load in there and chek in real time (that's what I followed).

since sometimes I am not working on CCS or TI and do not have that loaded in my PC. So, I may not give exact solutions.

You will have to learn CCS feature thoroughly before using that feature. If you still facing problem what you can do is you can send zip copy of your application (the code which is relavent to address problem) and post it. Other people can run on their CCS and can easily give you some tips.

Regards,
Ritesh

On 4/19/06, megha daga wrote: Dear Ritesh
Thanks for the reply. I am a bit immature at coding. Can you guide me a bit more on how to tackle that error. Where should I look for the PC and the SP. Well when i get that error the prog. stops at a particular addr. Are you talking about that addr. Cause thats perfectly fine. Can you elaborate a little for me: how to proceed for this debugging.
Actually when I load the program, I get one more error and thats : "RTDX target application does not match emulation protocol! Loaded program was created with rtdx library which does not match the target device." I know this error wont come when I am working on an actual board. Its coming on the simulator. Hence I am ignoring that error. Should I not do that? And if yes do you have any idea how to remove that?
Kindly help.
thanks
megha

Ritesh Patel wrote: Iterations on simulator will always be slow. 12000 iterations in 6 minutes is still good. If you replace your C code with Assembally (specially cycle consuming algorithms such as mathematical operations) then, simulator will run fast.

Trouble running Target CPU
Above error may occur for various reasons. See if your Program counter address showing some unusual value. This may also happen when SP stack pointer is corrupted and various other reason. you have to find out.

Ritesh

On 4/19/06, megha daga wrote: Hi Everyone
I am using PEP5416 to run an acoustic model. Right now I am testing/debugging just on the simulator C5416 and not on the actual device.
I am doing AGC/DRC for processing and for that I have to calculate the dB gain value. For that I am using following code:

for(i = 32768; i > 0;i--)
{
//determine the dB value of current point
logx = (float)20.0*(float)log10((float)i/(float)32768);
//now see if the current value is between the two
//points that we are now using
//if we are less than the first point, read
//in the next point from the file
if(logx < logx1)
{
//save previous values
logx2 = logx1;
logy2 = logy1;

//Read in the next point
fgets(temp, 250, fileid);
sscanf(temp, "%f%f", &logx1, &logy1);
}

//now interpolate logy from logx
logy = logy1+(logx-logx1)/(logx2-logx1)*(logy2-logy1);

//now convert to an actual gain
//gain = (desired ouput)/input
drctable[i] = (float)32768*(float)pow(10,logy/(float)20.0)/(float)i;
}

This command is taking a lot of time while debugging. I waited almost for 6 min and the counter ("i") just reached almost to 19000 and after that it gave an error as:
Trouble running Target CPU
What should I do for the speed and for this error?
Kindly reply.
Thanking You
Megha Daga

--
Ritesh Patel
M.Tech. IIT-Bombay

---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2�/min or less.

--
Ritesh Patel
M.Tech. IIT-Bombay

---------------------------------
How low will we go? Check out Yahoo! Messenger�s low PC-to-Phone call rates.

--
Ritesh Patel
M.Tech. IIT-Bombay

---------------------------------
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.