Hi,
Ich habe mal die erzeugte elf Datei von meinem Programm in das AVR
Studio zum simulieren geladen.
Ich möchte nun testen, wie lange eine bestimmte Funktion (sprintf)
braucht.
Ich dachte ich könnte das am Program Counter erkennen?!
Folgendes Programm habe ich mal durchgejagt:
1 | #include <inttypes.h>
|
2 | #include <stdio.h>
|
3 | #include <stdlib.h>
|
4 | #include <avr/io.h>
|
5 | #include <avr/interrupt.h>
|
6 | #include <avr/signal.h>
|
7 | #include "vardefs.h"
|
8 |
|
9 | #define nop() asm volatile("nop")
|
10 |
|
11 | #define V_Max 30
|
12 | #define ADC_res 1024.0
|
13 | #define ADC_mult (V_Max/ADC_res)
|
14 |
|
15 | int main(void)
|
16 | {
|
17 | s08 buf[6];
|
18 | u16 ADC_Val = 422;
|
19 | sprintf(buf,"% 5.1f", ADC_Val * ADC_mult - 15);
|
20 |
|
21 | while(1) nop();
|
22 | }
|
Vor dem sprintf() steht mein Program Counter auf 4B (hex). Nach dem
sprintf auf 5D (hex). Das macht eine differenz von 18. Also bräuchte
das ganze gesülz 18 Takte?
Das ist ja wohl zu schön um wahr zu sein ;)
Kann man sich wohl eher nicht drauf verlassen oder?