DSPRelated.com
Forums

printf

Started by Roger Kingsley February 8, 2005
printf

1.  For real-time debugging, use LOG_printf

2.  Even if it isn't a timing issue, if you have optimisation switched on, LOG_printf or printf can change the way the optimiser works, if there is a bug in the optimiser, it can change the behaviour.  Best to get the code working without optimisation first.

Roger Kingsley


   Date: Mon, 07 Feb 2005 07:15:41 -0500

   From: P...@gmx.de

Subject: Printf influences code?


Hi,

I have some strange problems with my DSP programm. For debugging I use the printf-function. The fwrite/fread-functions are also used for providing some process data.

The problem I have is, if I add or remove some printf statements, the results of some calculations are different. How can printf influence the behavior of my code?

If someone has any ideas, please tell me!

Puchowski



You might be corrupting memory, which is being masked by calling printf. Is
your code in C/ASM ? Would help if you could share your code.
Regards

Jagadeesh Sankaran
-----Original Message-----
From: Roger Kingsley [mailto:]
Sent: Tuesday, February 08, 2005 1:26 AM
To:
Cc: ;
Subject: [c6x] printf
1. For real-time debugging, use LOG_printf

2. Even if it isn't a timing issue, if you have optimisation switched on,
LOG_printf or printf can change the way the optimiser works, if there is a
bug in the optimiser, it can change the behaviour. Best to get the code
working without optimisation first.

Roger Kingsley
Date: Mon, 07 Feb 2005 07:15:41 -0500

From:

Subject: Printf influences code?
Hi,

I have some strange problems with my DSP programm. For debugging I use the
printf-function. The fwrite/fread-functions are also used for providing some
process data.

The problem I have is, if I add or remove some printf statements, the
results of some calculations are different. How can printf influence the
behavior of my code?

If someone has any ideas, please tell me!

Puchowski

. To



One more thing that might help. printf takes apprx 4000 cycles to
execute and thus takes arnd 26usec to execute @ 150Mhz

Tarang On Tue, 8 Feb 2005 07:35:46 -0600, sankaran <> wrote:
>
>
> You might be corrupting memory, which is being masked by calling printf. Is
> your code in C/ASM ? Would help if you could share your code.
>
> Regards
>
> Jagadeesh Sankaran > -----Original Message-----
> From: Roger Kingsley [mailto:]
> Sent: Tuesday, February 08, 2005 1:26 AM
> To:
> Cc: ;
> Subject: [c6x] printf
>
> 1. For real-time debugging, use LOG_printf
>
> 2. Even if it isn't a timing issue, if you have optimisation switched on,
> LOG_printf or printf can change the way the optimiser works, if there is a
> bug in the optimiser, it can change the behaviour. Best to get the code
> working without optimisation first.
>
> Roger Kingsley
>
> Date: Mon, 07 Feb 2005 07:15:41 -0500
>
> From:
>
> Subject: Printf influences code?
>
> Hi,
>
> I have some strange problems with my DSP programm. For debugging I use the
> printf-function. The fwrite/fread-functions are also used for providing some
> process data.
>
> The problem I have is, if I add or remove some printf statements, the
> results of some calculations are different. How can printf influence the
> behavior of my code?
>
> If someone has any ideas, please tell me!
>
> Puchowski >
> . To



Hello Tarang,
 
This might be a correct statement for your PC, your OS and tour emulator - but it is not "universally true".
 
I will repeat myself since this is foreign to many inexperienced embedded developers - the host must poll the target, detect that it is halted at the correct  breakpoint, read a cmd, read the raw 'printf buffer', process it and print it to the screen.
 
The variables in this process are:
PC speed, PC OS, PC response time [sometimes variable], emulator speed and target speed.
 
mikedunn

Tarang Dadia <t...@gmail.com> wrote:
One more thing that might help. printf takes apprx 4000 cycles to
execute and thus takes arnd 26usec to execute @ 150Mhz

TarangOn Tue, 8 Feb 2005 07:35:46 -0600, sankaran wrote:> You might be corrupting memory, which is being masked by calling printf. Is
> your code in C/ASM ? Would help if you could share your code.
>
> Regards
>
> Jagadeesh Sankaran> -----Original Message-----
> From: Roger Kingsley [mailto:r...@scopus.net]
> Sent: Tuesday, February 08, 2005 1:26 AM
> To: c...@yahoogroups.com
> Cc: P...@gmx.de; m...@sbcglobal.net
> Subject: [c6x] printf
>
> 1. For real-time debugging, use LOG_printf
>
> 2. Even if it isn't a timing issue, if you have optimisation switched on,
> LOG_printf or printf can change the way the optimiser works, if there is a
> bug in the optimiser, it can change the behaviour. Best to get the code
> working without optimisation first.
>
> Roger Kingsley
>
> Date: Mon, 07 Feb 2005 07:15:41 -0500
>
> From: P...@gmx.de
>
> Subject: Printf influences code?
>
> Hi,
>
> I have some strange problems with my DSP programm. For debugging I use the
> printf-function. The fwrite/fread-functions are also used for providing some
> process data.
>
> The problem I have is, if I add or remove some printf statements, the
> results of some calculations are different. How can printf influence the
> behavior of my code?
>
> If someone has any ideas, please tell me!
>
> Puchowski>
> . To>
>
> <*> To visit your group on the web, go to:
> http://groups.yahoo.com/group/c6x/
>
> <*> To unsubscribe from this group, send an email to:
> c...@yahoogroups.com
>
> <*



Hi!

First thanks for your help. I found the reason for this strange behaviour. There was an uninitialised enum-type variable in my C code. I was porting software from Windows to DSP and the behaviour of the TI-compiler sometimes is a little bit different from Microsoft's one. For example in this case the Microsoft-compiler did the initialisation by itself, the TI-compiler did not. So I had created some kind of random everytime I changed the printf-statements for debugging

D. Puchowski
>
> printf
>
> 1. For real-time debugging, use LOG_printf
> 2. Even if it isn't a timing issue, if you have optimisation switched on, LOG_printf or printf can change the way the optimiser works, if there is a bug in the optimiser, it can change the behaviour. Best to get the code working without optimisation first.
> Roger Kingsley
>
> Date: Mon, 07 Feb 2005 07:15:41 -0500
> From:
> Subject: Printf influences code?
>
> Hi,
> I have some strange problems with my DSP programm. For debugging I use the printf-function. The fwrite/fread-functions are also used for providing some process data.
> The problem I have is, if I add or remove some printf statements, the results of some calculations are different. How can printf influence the behavior of my code?
> If someone has any ideas, please tell me!
> Puchowski