DSPRelated.com
Forums

Re: read an external text file in CCS5416

Started by Jeff Brower April 16, 2006
Megha-

> I used it in following manner:
> if((fileid = fopen( "C:\CCStudio_v3.1\boards\pep5416\examples\test\test",
> "r" )) == NULL )

Ok, ur not a C programmer yet. Try this way:

if((fileid = fopen(
"C:\\CCStudio_v3.1\\boards\\pep5416\\examples\\test\\test", "r" )) =NULL )

-Jeff

> Jeff Brower wrote: Megha-
>
>> I also tried what you suggested: to give the whole path for the file but
>> then it printed a worning statemnet :
>> "test.c", line 10: warning: unrecognized character escape sequence
>
> You can't let yourself get stuck on a compiler problem when you're trying
> to debug -- debug is much too important for that.
>
> Did you make sure to use "\\" (double back-slash) in your path string?
> Show us the path string that you used.
>
> -Jeff
>
>> Jeff Brower wrote: Megha-
>>
>>> I think some or the other time, someone might have read data from an
>>> external file in CCS. I am trying to do the same.
>>> As I wrote in previous mail I am reading data from a prm(text) file. I
>>> am
>>> using fopen(), scanf() and functions like that from stdio.h. But CCS is
>>> not running the program. its not opening the file only.
>>
>> Did you try an explicit path instead of only "8chF.prm" ?
>>
>> When this happens, what are the values of errno, and strerror(errno)?
>> Maybe you can do a debug printf statement:
>>
>> printf("Mega cannot open file! Error %i, %s\n", errno,
>> strerror(errno));
>>
>> to help figure it out.
>>
>> -Jeff
>>> megha daga wrote: hey everyone
>>> I am working on PEP5416 and using CCS5416 as simulator. Well in my code
>>> I
>>> am reading data from a prm(text) file. I am reading the data and
>>> scaning
>>> it and storing the value as follows:
>>>
>>> if( (fileid = fopen( "8chF.prm", "r" )) == NULL )
>>> {
>>> exit(1);
>>> }
>>>
>>> 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;
>>> }
>>> }
>>>
>>> Well as you will notice I am opening a file and then reading 250 chars
>>> and
>>> seeing where NUMCHAN occurs. As soon as I get the match I store the
>>> value
>>> following in the next 250 chars of NUMCHAN in numchan.
>>> Well my problem is that simulator is not opening the file only. Its not
>>> reading the file. When i do step by step debugging, I notice that after
>>> "fopen" statement the debugger cursor goes to "exit(1)" instead of
>>> "while". I have included the proper header file too (stdio.h). Well the
>>> prm file is stored inside the same folder. Everything is there. there
>>> is
>>> no building error. I dont understand why its doing that.
>>> I hope I am able to expalin my problem.
>>> Someone kindly reply and help me out.
>>> Thanking You
>>> Megha Daga
>
> ---------------------------------
> Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great
> rates starting at 1/min.
Hi jeff
thanks. Well I found the error. I actually stored the file in the main folder. I need to store it in the debug folder to access it. I am able to access the data now.
Thanks
megha

Jeff Brower wrote: Megha-

> I used it in following manner:
> if((fileid = fopen( "C:\CCStudio_v3.1\boards\pep5416\examples\test\test",
> "r" )) == NULL )

Ok, ur not a C programmer yet. Try this way:

if((fileid = fopen(
"C:\\CCStudio_v3.1\\boards\\pep5416\\examples\\test\\test", "r" )) =NULL )

-Jeff

> Jeff Brower wrote: Megha-
>
>> I also tried what you suggested: to give the whole path for the file but
>> then it printed a worning statemnet :
>> "test.c", line 10: warning: unrecognized character escape sequence
>
> You can't let yourself get stuck on a compiler problem when you're trying
> to debug -- debug is much too important for that.
>
> Did you make sure to use "\\" (double back-slash) in your path string?
> Show us the path string that you used.
>
> -Jeff
>
>> Jeff Brower wrote: Megha-
>>
>>> I think some or the other time, someone might have read data from an
>>> external file in CCS. I am trying to do the same.
>>> As I wrote in previous mail I am reading data from a prm(text) file. I
>>> am
>>> using fopen(), scanf() and functions like that from stdio.h. But CCS is
>>> not running the program. its not opening the file only.
>>
>> Did you try an explicit path instead of only "8chF.prm" ?
>>
>> When this happens, what are the values of errno, and strerror(errno)?
>> Maybe you can do a debug printf statement:
>>
>> printf("Mega cannot open file! Error %i, %s\n", errno,
>> strerror(errno));
>>
>> to help figure it out.
>>
>> -Jeff
>>> megha daga wrote: hey everyone
>>> I am working on PEP5416 and using CCS5416 as simulator. Well in my code
>>> I
>>> am reading data from a prm(text) file. I am reading the data and
>>> scaning
>>> it and storing the value as follows:
>>>
>>> if( (fileid = fopen( "8chF.prm", "r" )) == NULL )
>>> {
>>> exit(1);
>>> }
>>>
>>> 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;
>>> }
>>> }
>>>
>>> Well as you will notice I am opening a file and then reading 250 chars
>>> and
>>> seeing where NUMCHAN occurs. As soon as I get the match I store the
>>> value
>>> following in the next 250 chars of NUMCHAN in numchan.
>>> Well my problem is that simulator is not opening the file only. Its not
>>> reading the file. When i do step by step debugging, I notice that after
>>> "fopen" statement the debugger cursor goes to "exit(1)" instead of
>>> "while". I have included the proper header file too (stdio.h). Well the
>>> prm file is stored inside the same folder. Everything is there. there
>>> is
>>> no building error. I dont understand why its doing that.
>>> I hope I am able to expalin my problem.
>>> Someone kindly reply and help me out.
>>> Thanking You
>>> Megha Daga
>
Hi Everyone
I am not able to allocate the memory properly in C5416. I am not able to understand which part should be allocated IDATA, IPROG, DARAM, SARAM...
I need to use the external memory and hence i am using the SARAM and DARAM. I have allocated the memory but I am getting an error as
Trouble Running Target CPU.
When I click on Go Main after loading the file, the cursor goes to some random location in my code. Its not going to the Main(). And its giving the above error. I think its due to unproper allocation of memory. I am attaching my code. I am working on TI C5416 simulator. If its possible for you to see and suggest something on the memory allocation (in cdb file System -> MEM -> right click properties), kindly do that.
Thanking You
Megha Daga
Jeff Brower wrote: Megha-

> I used it in following manner:
> if((fileid = fopen( "C:\CCStudio_v3.1\boards\pep5416\examples\test\test",
> "r" )) == NULL )

Ok, ur not a C programmer yet. Try this way:

if((fileid = fopen(
"C:\\CCStudio_v3.1\\boards\\pep5416\\examples\\test\\test", "r" )) =NULL )

-Jeff

> Jeff Brower wrote: Megha-
>
>> I also tried what you suggested: to give the whole path for the file but
>> then it printed a worning statemnet :
>> "test.c", line 10: warning: unrecognized character escape sequence
>
> You can't let yourself get stuck on a compiler problem when you're trying
> to debug -- debug is much too important for that.
>
> Did you make sure to use "\\" (double back-slash) in your path string?
> Show us the path string that you used.
>
> -Jeff
>
>> Jeff Brower wrote: Megha-
>>
>>> I think some or the other time, someone might have read data from an
>>> external file in CCS. I am trying to do the same.
>>> As I wrote in previous mail I am reading data from a prm(text) file. I
>>> am
>>> using fopen(), scanf() and functions like that from stdio.h. But CCS is
>>> not running the program. its not opening the file only.
>>
>> Did you try an explicit path instead of only "8chF.prm" ?
>>
>> When this happens, what are the values of errno, and strerror(errno)?
>> Maybe you can do a debug printf statement:
>>
>> printf("Mega cannot open file! Error %i, %s\n", errno,
>> strerror(errno));
>>
>> to help figure it out.
>>
>> -Jeff
>>> megha daga wrote: hey everyone
>>> I am working on PEP5416 and using CCS5416 as simulator. Well in my code
>>> I
>>> am reading data from a prm(text) file. I am reading the data and
>>> scaning
>>> it and storing the value as follows:
>>>
>>> if( (fileid = fopen( "8chF.prm", "r" )) == NULL )
>>> {
>>> exit(1);
>>> }
>>>
>>> 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;
>>> }
>>> }
>>>
>>> Well as you will notice I am opening a file and then reading 250 chars
>>> and
>>> seeing where NUMCHAN occurs. As soon as I get the match I store the
>>> value
>>> following in the next 250 chars of NUMCHAN in numchan.
>>> Well my problem is that simulator is not opening the file only. Its not
>>> reading the file. When i do step by step debugging, I notice that after
>>> "fopen" statement the debugger cursor goes to "exit(1)" instead of
>>> "while". I have included the proper header file too (stdio.h). Well the
>>> prm file is stored inside the same folder. Everything is there. there
>>> is
>>> no building error. I dont understand why its doing that.
>>> I hope I am able to expalin my problem.
>>> Someone kindly reply and help me out.
>>> Thanking You
>>> Megha Daga
>
> ---------------------------------
> Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great
> rates starting at 1�/min.

---------------------------------
Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just 2/min with Yahoo! Messenger with Voice.
Dear Megha Daga,

there is one book "digital signal processing" by avatar singh which is specially written for TMS320C5416.

When you are using extended memory feature in C5416 processor, you should change some register values in GEL file. As well as you have to change the lib file to rts_ext.lib.
I did my porting work of AMR Decoder on this processor using extended memory. for further clarifications send me mail stating clear cut problem.

regards
Sridhar. A
VoIP Engineer.
Hellosoft India pvt. ltd

megha daga wrote:
Hi Everyone
I am not able to allocate the memory properly in C5416. I am not able to understand which part should be allocated IDATA, IPROG, DARAM, SARAM...
I need to use the external memory and hence i am using the SARAM and DARAM. I have allocated the memory but I am getting an error as
Trouble Running Target CPU.
When I click on Go Main after loading the file, the cursor goes to some random location in my code. Its not going to the Main(). And its giving the above error. I think its due to unproper allocation of memory. I am attaching my code. I am working on TI C5416 simulator. If its possible for you to see and suggest something on the memory allocation (in cdb file System -> MEM -> right click properties), kindly do that.
Thanking You
Megha Daga
Jeff Brower wrote: Megha-

> I used it in following manner:
> if((fileid = fopen( "C:\CCStudio_v3.1\boards\pep5416\examples\test\test",
> "r" )) == NULL )

Ok, ur not a C programmer yet. Try this way:

if((fileid = fopen(
"C:\\CCStudio_v3.1\\boards\\pep5416\\examples\\test\\test", "r" )) =NULL )

-Jeff

> Jeff Brower wrote: Megha-
>
>> I also tried what you suggested: to give the whole path for the file but
>> then it printed a worning statemnet :
>> "test.c", line 10: warning: unrecognized character escape sequence
>
> You can't let yourself get stuck on a compiler problem when you're trying
> to debug -- debug is much too important for that.
>
> Did you make sure to use "\\" (double back-slash) in your path string?
> Show us the path string that you used.
>
> -Jeff
>
>> Jeff Brower wrote: Megha-
>>
>>> I think some or the other time, someone might have read data from an
>>> external file in CCS. I am trying to do the same.
>>> As I wrote in previous mail I am reading data from a prm(text) file. I
>>> am
>>> using fopen(), scanf() and functions like that from stdio.h. But CCS is
>>> not running the program. its not opening the file only.
>>
>> Did you try an explicit path instead of only "8chF.prm" ?
>>
>> When this happens, what are the values of errno, and strerror(errno)?
>> Maybe you can do a debug printf statement:
>>
>> printf("Mega cannot open file! Error %i, %s\n", errno,
>> strerror(errno));
>>
>> to help figure it out.
>>
>> -Jeff
>>> megha daga wrote: hey everyone
>>> I am working on PEP5416 and using CCS5416 as simulator. Well in my code
>>> I
>>> am reading data from a prm(text) file. I am reading the data and
>>> scaning
>>> it and storing the value as follows:
>>>
>>> if( (fileid = fopen( "8chF.prm", "r" )) == NULL )
>>> {
>>> exit(1);
>>> }
>>>
>>> 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;
>>> }
>>> }
>>>
>>> Well as you will notice I am opening a file and then reading 250 chars
>>> and
>>> seeing where NUMCHAN occurs. As soon as I get the match I store the
>>> value
>>> following in the next 250 chars of NUMCHAN in numchan.
>>> Well my problem is that simulator is not opening the file only. Its not
>>> reading the file. When i do step by step debugging, I notice that after
>>> "fopen" statement the debugger cursor goes to "exit(1)" instead of
>>> "while". I have included the proper header file too (stdio.h). Well the
>>> prm file is stored inside the same folder. Everything is there. there
>>> is
>>> no building error. I dont understand why its doing that.
>>> I hope I am able to expalin my problem.
>>> Someone kindly reply and help me out.
>>> Thanking You
>>> Megha Daga
>