* Best way to determine tb_ticks_per_jiffy inside todc_calibrate_decr()
@ 2005-04-08 8:45 Daniel Ann
2005-04-08 18:32 ` Mark A. Greer
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Ann @ 2005-04-08 8:45 UTC (permalink / raw)
To: linuxppc-embedded
Hey folks,
I seem to have problem getting 1 second right. Board has no RTC so
I've basically NULLed all the todc_XXX functions except
todc_calibrate_decr.
Now question is, what value should I be assigning it to tb_ticks_per_jiffy ?
I was able to dig up some info from the archive, and it read,
=-=-=-FROM ARCHIVE =-=-=-
You must find this value by yourself but a good starting point is your
frequency in Hz (I think)
Example of the code
unsigned int freq = 28000000;
tb_tick_per_jiffy = freq/HZ;
tb_to_us = mulhwu_scale_factor(freq,1000000);
=-=-=-END OF ARCHIVE =-=-=-
I'm fine with working it out myself but where do I start ? My board
has 33MHz OSC, so I've trie freq = 33 * 1000000 (where HZ is defined
100) but it turned out to be little short. I could have just tried few
more trial and error, but I prefer knowing what I'm doing so.. :)
Before I was trying it with 100 * 1000000 which had delays like 10:1.
Now its only about 1.5:1. So, I guess I'm on the right track.... so
can anyone please help me out here?
Also, could anyone spill their brain on mulhwu_scale_factor() ? I've
followed the code and ended up reading what seems to be a assembler.
(Should have paid attention during the lectures :P) Any hint on this ?
Thanks heaps..
Cheers,
--
Daniel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Best way to determine tb_ticks_per_jiffy inside todc_calibrate_decr()
2005-04-08 8:45 Best way to determine tb_ticks_per_jiffy inside todc_calibrate_decr() Daniel Ann
@ 2005-04-08 18:32 ` Mark A. Greer
2005-04-09 1:29 ` Daniel Ann
0 siblings, 1 reply; 5+ messages in thread
From: Mark A. Greer @ 2005-04-08 18:32 UTC (permalink / raw)
To: Daniel Ann; +Cc: linuxppc-embedded
Daniel,
Daniel Ann wrote:
>Hey folks,
>
>I seem to have problem getting 1 second right. Board has no RTC so
>I've basically NULLed all the todc_XXX functions except
>todc_calibrate_decr.
>
If you don't have an RTC, you shouldn't be using any todc_xxx routines.
>
>Now question is, what value should I be assigning it to tb_ticks_per_jiffy ?
>
>I was able to dig up some info from the archive, and it read,
>=-=-=-FROM ARCHIVE =-=-=-
>You must find this value by yourself but a good starting point is your
>frequency in Hz (I think)
>Example of the code
> unsigned int freq = 28000000;
> tb_tick_per_jiffy = freq/HZ;
> tb_to_us = mulhwu_scale_factor(freq,1000000);
>=-=-=-END OF ARCHIVE =-=-=-
>
>I'm fine with working it out myself but where do I start ? My board
>has 33MHz OSC, so I've trie freq = 33 * 1000000 (where HZ is defined
>100) but it turned out to be little short. I could have just tried few
>more trial and error, but I prefer knowing what I'm doing so.. :)
>
There are several platform files that explicitly set tb_ticks_per_jiffy
and tb_to_us. Did you try looking at those?
Also, 33MHz does not sound right but then you don't say what processor
you're using so who knows. You need to find the bus freq used by the
cpu/system. Try looking for the freq of the processor's SYSCLK input.
Then you probably have to divide that by 4 to get the frequency that the
decrementer runs at. That's the value that you should use for the
'freq' variable in the example code you included in your email.
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Best way to determine tb_ticks_per_jiffy inside todc_calibrate_decr()
2005-04-08 18:32 ` Mark A. Greer
@ 2005-04-09 1:29 ` Daniel Ann
2005-04-11 18:39 ` Mark A. Greer
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Ann @ 2005-04-09 1:29 UTC (permalink / raw)
To: Mark A. Greer; +Cc: linuxppc-embedded
On Apr 9, 2005 3:32 AM, Mark A. Greer <mgreer@mvista.com> wrote:
> If you don't have an RTC, you shouldn't be using any todc_xxx routines.
Yeah, I figured this much :)
> There are several platform files that explicitly set tb_ticks_per_jiffy
> and tb_to_us. Did you try looking at those?
Actually that didnt occur to me since I thought it was related to the
supplied oscillator. Not knowing what their board is equiped with, I
couldnt trust their value any more than my estimated value. But
reading your next comment, it seems that it's related to processor as
well.
> Also, 33MHz does not sound right but then you don't say what processor
> you're using so who knows. You need to find the bus freq used by the
> cpu/system. Try looking for the freq of the processor's SYSCLK input.
> Then you probably have to divide that by 4 to get the frequency that the
> decrementer runs at. That's the value that you should use for the
> 'freq' variable in the example code you included in your email.
Okay guess I had all these things mixed up in head. What I should have
said is, source to PCI_SYNC_IN is 33MHz.
Anyway, following the MPC8245 hardware Spec pdf file, I was able to
find the peripheral logic/memory bus clock to be 99,000,000. Dividing
that by 4 like you said, gave me the value of 24,750,000. Which is
I've used it to get very real 1 second :)
BTW, why do you have to divide it by 4 ?
--
Daniel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Best way to determine tb_ticks_per_jiffy inside todc_calibrate_decr()
2005-04-09 1:29 ` Daniel Ann
@ 2005-04-11 18:39 ` Mark A. Greer
2005-04-12 3:55 ` Daniel Ann
0 siblings, 1 reply; 5+ messages in thread
From: Mark A. Greer @ 2005-04-11 18:39 UTC (permalink / raw)
To: Daniel Ann; +Cc: linuxppc-embedded
Daniel Ann wrote:
>On Apr 9, 2005 3:32 AM, Mark A. Greer <mgreer@mvista.com> wrote:
>
>
>>Also, 33MHz does not sound right but then you don't say what processor
>>you're using so who knows. You need to find the bus freq used by the
>>cpu/system. Try looking for the freq of the processor's SYSCLK input.
>>Then you probably have to divide that by 4 to get the frequency that the
>>decrementer runs at. That's the value that you should use for the
>>'freq' variable in the example code you included in your email.
>>
>>
>
>Okay guess I had all these things mixed up in head. What I should have
>said is, source to PCI_SYNC_IN is 33MHz.
>
Ah, that sounds reasonable. ;)
>Anyway, following the MPC8245 hardware Spec pdf file, I was able to
>find the peripheral logic/memory bus clock to be 99,000,000. Dividing
>that by 4 like you said, gave me the value of 24,750,000. Which is
>I've used it to get very real 1 second :)
>
Cool.
>
>BTW, why do you have to divide it by 4 ?
>
Because the internally kept time in ppc linux is based on the
decrementer counter and, according to the manual for the 8245, the
decrementer counter is decremented once every four sys_logic_clk
cycles. Therefore, you need to divide by 4.
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Best way to determine tb_ticks_per_jiffy inside todc_calibrate_decr()
2005-04-11 18:39 ` Mark A. Greer
@ 2005-04-12 3:55 ` Daniel Ann
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Ann @ 2005-04-12 3:55 UTC (permalink / raw)
To: Mark A. Greer; +Cc: linuxppc-embedded
On Apr 12, 2005 3:39 AM, Mark A. Greer <mgreer@mvista.com> wrote:
> Because the internally kept time in ppc linux is based on the
> decrementer counter and, according to the manual for the 8245, the
> decrementer counter is decremented once every four sys_logic_clk
> cycles. Therefore, you need to divide by 4.
Gotcha. Thanks ^^
--
Daniel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-04-12 3:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-08 8:45 Best way to determine tb_ticks_per_jiffy inside todc_calibrate_decr() Daniel Ann
2005-04-08 18:32 ` Mark A. Greer
2005-04-09 1:29 ` Daniel Ann
2005-04-11 18:39 ` Mark A. Greer
2005-04-12 3:55 ` Daniel Ann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).