Hi there,
I used 200MHz GTC timer, as enabled in the examples, to measure its own access time, using of two consecutive reads. I have inline function to read 32-bits of the timer like this:
static inline uint32_t GetTimer(void)
{
return (*(volatile uint32_t*)(0xa90000UL + 0x8U));
}
Here is my test code:
...
uint32_t t1 = GetTimer();
uint32_t t2 = GetTimer();
printf("### Info: GetTimer time offset: %u ns\n", (t2 - t1) * 5u );
...
To be sure, I checked the assembly where we can see two read accesses where the address is loaded in the r4 already. Next, there is subtraction, multiplication by 5 (200MHz is 5ns) made via adding and printf call. Simple clean code w/o any overhead.
; return (*(volatile uint32_t*)(0xa90000UL + 0x8U));
a22540c8: 00 00 94 e5 ldr r0, [r4]
a22540cc: 00 10 94 e5 ldr r1, [r4]
; printf("### Info: GetTimer time offset: %u ns\n", (t2 - t1) * 5u );
a22540d0: 00 00 41 e0 sub r0, r1, r0
a22540d4: 00 11 80 e0 add r1, r0, r0, lsl #2
a22540d8: 3c 03 9f e5 ldr r0, [pc, #828]
a22540dc: 4f 22 00 eb bl #35132 <printf>
Then, I'm getting this text on the Linux IPC logging utility, all the time:
### Info: GetTimer time offset: 235 ns
If I consider 1GHz R5F clock, I found 235 ns simply too long time, especially in comparison to pure embedded ARM cores like M4/M7, where are peripherals accessed w/o any significant wait states. Is there any explanation or did I something wrong or even is not the CPU running at that speed, even logging message says " ### CPU Frequency = 1000000000 Hz" and verified 200MHz GTC clock? I used shipping vison-example and I placed my small code into the app_init.c file after the init phase.
Thanks a lot.
Best regards,
Tomas