Technical discussions about the TI C55x DSPs (including the c5501, c5502, c5503, c5507, c5509, c5510 and OMAP5910).
1. This works:
char *myArr = "Hello";
LOG_printf(&trc, "%s", myArr);
but this does not:
char myArr[128] = "Hello";
LOG_printf(&trc, "%s", myArr);
Does anybody know the logic behind this???
2. char *myArr;
myArr = (char *) MEM_alloc(SEG0, 128*sizeof(char), 0);
...
(after some calculations)
...
printf("%s", myArr); //This works
LOG_printf(&trc, "%s", myArr); //This is giving an error message
//in LOG window: "*** ERROR: ..."
why might printf work but LOG_printf does not, when inputs are same???
Thanks in advance..
Murat.
Check Out Industry's First Single-Chip, Multi-Format, Real-Time HD Video Transcoding Solution
for Commercial & Consumer End Equipment: www.ti.com/dm6467
The LOG subsystem does not actually store your string, only a pointer
to the format string and the arguments. The resultant formatted
string isn't created until you ask CCS to display it. The reason why
it doesn't work is because you are passing a pointer to a stack
location which is not valid outside of the context of the routine
making the call. In other words, any subsequent function calls (or
possibly interrupts, depending on which stack you're using) are
overwriting your string contents.
The printf function is different, in that it is immediately creating
the resultant string (tyically with some of it's own local storage)
and sending that result to the console.
--- In c...@yahoogroups.com, muonder@... wrote:
>
> 1. This works:
>
> char *myArr = "Hello";
> LOG_printf(&trc, "%s", myArr);
>
> but this does not:
>
> char myArr[128] = "Hello";
> LOG_printf(&trc, "%s", myArr);
>
> Does anybody know the logic behind this???
>
> 2. char *myArr;
> myArr = (char *) MEM_alloc(SEG0, 128*sizeof(char), 0);
> ...
> (after some calculations)
> ...
> printf("%s", myArr); //This works
> LOG_printf(&trc, "%s", myArr); //This is giving an error message
> //in LOG window: "*** ERROR: ..."
>
> why might printf work but LOG_printf does not, when inputs are
same???
>
> Thanks in advance..
>
> Murat.
>
Check Out Industry's First Single-Chip, Multi-Format, Real-Time HD Video Transcoding Solution
for Commercial & Consumer End Equipment: www.ti.com/dm6467