[U-Boot-Users] main clock calculation invalid

Wolfgang Denk wd at denx.de
Thu Apr 19 20:14:14 CEST 2007


In message <0721A2B6C14.000002EAejr at inbox.com> you wrote:
>
> > I'm sorry, but the user's manual for my Z80 processor does not contain
...
> I'm not sure what you're missing but my emphasis was on the calculation. 
> This is on an ARM9 LH7A404 chip. Now I might be missing something but even
> on a 16 bit CPU

You did not understand my little joke about the old Z80 CPU - what  I
wanted  to  pointout  was  that  you completely left out all relevant
information, like which architecture  and  CPU  and  board  you  were
talking about.

> the calculation result shouldn't change, no?

You might have overflows here and there...

> and CONFIG_SYS_CLK_FREQ is 14745600.

It should probably be 14745600L or "UL".

>     ulong maindiv1, maindiv2, prediv, ps;
      ^^^^^
>     printf("maindiv2: %d, maindiv1 %d, prediv %d, ps %d\n",maindiv2,maindiv1,prediv,ps);
                        ^^           ^^         ^^     ^^

%d is for int, not for ulong.

>     printf("CONFIG_SYS_CLK_FREQ: %d \n",CONFIG_SYS_CLK_FREQ);

Same here.

>     return ( ((maindiv2 + 2) * (maindiv1 + 2) * CONFIG_SYS_CLK_FREQ) /
> ((prediv + 2) * (1 << ps)));



Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, HRB 165235 Munich, CEO: Wolfgang Denk
Office:  Kirchenstr. 5,       D-82194 Groebenzell,            Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
What was sliced bread the greatest thing since?




More information about the U-Boot mailing list