Mesaure the execution time of my C functions

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Mesaure the execution time of my C functions

5,968件の閲覧回数
Richard777
Contributor I
Hi, sorry for my bad english, I use HCS08 with P&E MultiLink USB real time debugger, How I do mesaure execution time of my "C" functions ?
 
Best regards !


Message Edited by Richard777 on 2008-11-16 08:56 PM
ラベル(1)
0 件の賞賛
返信
17 返答(返信)

2,071件の閲覧回数
bigmac
Specialist III
Hello Richard,

I cannot speak for the P&E debugger, but if you make use of the true time simulator associated with CW, this will provide the elapsed number of CPU cycles ( = bus cycles) during the simulation process.  It then becomes a matter of noting the CPU cycles prior to and immediately following execution of a function.

To accurately determine the number of cycles required for the function itself, interrupts should be globally disabled prior to calling the function.

In practice, worst case timings will also need to take into account the number of cycles required by any ISR that may potentially interrupt execution of the particular function.

Regards,
Mac

0 件の賞賛
返信

2,071件の閲覧回数
Richard777
Contributor I
Thanks Lundin and BigMac for your fast responces, BigMac my problem is that don't use the Simulator becuase I'm using the Real time debugger, I will try add some debug code in timers like Lundin say.
 
Best regards !
0 件の賞賛
返信

2,071件の閲覧回数
bigmac
Specialist III
Hello Richard,

I still think that it would be overall less time consuming to create a new CW project, and import the files containing the functions that you wish to test into the project.  However, I do see that there may be some timing differences, depending on the efficiency of the compiler you are using, compared with the CW compiler.

Regards,
Mac

0 件の賞賛
返信

2,071件の閲覧回数
peg
Senior Contributor IV
Hello,

Bigmac - I think Richard is using Codewarrior/Hiwave and his reference to P&E is his BDM adapter only.

Richard - Is this correct you are running the "Real Time Debugger" from "Codewarrior"?

Sorry, no time to actually help, but thought I would help guide those that are.
0 件の賞賛
返信

2,071件の閲覧回数
Richard777
Contributor I
Hi Peg, your afirmation it's correct, I'm usign CodeWarrior/Hiwave with Multilink P&E as BDM.
 
Best regards !
0 件の賞賛
返信

2,071件の閲覧回数
Richard777
Contributor I
Hi guys, I implement a simple solution for my problem, I have the TPM1 without use and my bus clock is the 14.7456 Mhz then set the TPM1CH0 like free running counter and set prescaler to 128.
 
Code:
... /* Configure TPM1 */ TPM1SC = 0;         TPM1MOD = 0; TPM1C0SC = 0x10; TPM1C0V = 0; /* Reset timer */ TPM1CNTH = 0; /* Set internal bus clock and prescaler to 128 */ TPM1SC = 0x0F; MyCFunctions(); /* Read the counter value */ Value = TPM1CNT; /* Reset timer */ TPM1CNTH = 0x00; OtherCFuntion(); Value = TPM1CNT;

 
Each unit in the value vars correspond aprox to 8.68 us, this is enough for me.
 
Best regards !
 
0 件の賞賛
返信

2,071件の閲覧回数
admin
Specialist II
Hi Richard

You and I seem to be working on a similar project. I too am reading/writing to an SD card, and I thought you may find it interesting to see what read/write times I am getting. I'm using an MC9S08GT60A @ 14.68MHz, and a sector read executes in 2.7ms and a write in about 3.5ms. In my app I'm reading a WAV file for voice reproduction while at the same time writing to a WAV file for recording, so timing was everything.


Edit: Corrected spelling.

Message Edited by Wingsy on 2008-11-26 11:40 AM
0 件の賞賛
返信

2,071件の閲覧回数
Richard777
Contributor I
Hello Wingsy, thanks for your information, your times is in card raw mode or with file system ?
 
Best regards !
0 件の賞賛
返信

2,071件の閲覧回数
admin
Specialist II
File system (FAT16 only), but those times are for just a sector read and sector write. The actual code time for all the stuff in between reads & writes is insignificant compared to the read/write times. But worst case read times must account for 2 sector reads for the case when you jump from 1 cluster to another, since the FAT needs to be read to obtain the next sector number.

Writes were a bitch. Since I'm recording directly to the card there just isn't enough time to append additional clusters to a file being written to, because you may have to search the entire FAT to find the next cluster. So what I did was to allocate a file big enough to hold the largest recording then write to those sectors already marked off in the cluster chain. Then at the end go back and free up the unused clusters and set the file size. There is enough time to play one sound file while simultaneously recording to another, but just barely.

Hope this helps you determine if you have enough time to do what you're doing.
0 件の賞賛
返信

2,071件の閲覧回数
Richard777
Contributor I
Hi BigMac, I try mesaure time with my hardware, this connect MC9S08SH32 with SD memory, I try mesaure the time of read and write functions, I can't use the simulator for this reason.
 
The proyect link is this, is in spanish but the source code have english comments.
 
 
Best regards.
 
I try use a free timer for mesaured time of my internal functions.
 
 
0 件の賞賛
返信

2,071件の閲覧回数
Lundin
Senior Contributor IV
Easiest way is to use an oscilloscope.

There is no magic built-in time meassure function in the IDE, so if you lack an oscilloscope you will have to write some debug code using the internal timers and then check the result in the debugger. Or the hard way, dissassemble and look up the number of ticks each assembler instruction takes.
0 件の賞賛
返信

2,071件の閲覧回数
alexod
Contributor I
I typically use test points for timing.  My HW guy and I agree that if we have a spare pin we should use it for a generic test point.  I'm typically looking to see that things happen well on a busy system.

I've been using CW with beans, and I find that a TP generally gets implemented as a single indivisible instruction on the S08's I've been using lately.  On other architectures there is some page accessing or other overhead in the "poke" to pin.

Depending on the accuracy you need, you may want to just wiggle you test point and determine the minimum on time of the TP, and subtract this from your execution time when you measure your function.

Using internal timers is good, but you have to get the results back out.  You will either want an array to save your timing results, say for the first hundred iterations and see if it comes out even.
0 件の賞賛
返信

2,071件の閲覧回数
Richard777
Contributor I
Hi Alexod, thanks for your suggestion !
 
 
0 件の賞賛
返信

2,071件の閲覧回数
Darukur
Contributor I

Hi Richard, nice to see you!!!

 

So you´re teaching the good pratices here too?

 

Regards!

0 件の賞賛
返信

2,071件の閲覧回数
Richard777
Contributor I

Hello Marcelo :smileyhappy: . No, in this forum all gays are all excelent programmers.

 

See you !

 

Message Edited by NLFSJ on 2009-08-18 10:04 AM
0 件の賞賛
返信

2,071件の閲覧回数
admin
Specialist II

Hola Richard777:

 

Hola e  seguido tu post hasta:

http://www.sistemasembebidos.com.ar/forum/index.php?topic=456.0

 

Magnifico trabajo ,estoy intentando realizar un proyecto parecido pero para el micro GT60, en el post  tu hablas de 5 librerias:

"Micrologger.c"

"Misc.c/Misc.h"

"FS.c/FS.h"

"Card.c/Card.h"

"MCU.c/MCU.h"

 

En el post tu diceas que las vas a subir pero no lo veo haci:

 

Me gustaria, "En la medida de lo posible" que me indicaras donde puedo descargar estas librerias o donde se encuentran, estoy trabajando con Code Warrior 6.0, Gracias por tu ayuda.

0 件の賞賛
返信

2,071件の閲覧回数
Richard777
Contributor I

Hello ( my natural languaje is spanish but in this forun I write in english ), try download in this site, inside zip file I wrote examples for HCS08SH32 and V1 Core.

 

http://sourceforge.net/projects/microfs/

 

Best regards

0 件の賞賛
返信