[U-Boot-Users] main clock calculation invalid

Martin Krause Martin.Krause at tqs.de
Fri Apr 20 09:17:45 CEST 2007


Hi Junior,

u-boot-users-bounces at lists.sourceforge.net wrote on Thursday, April 19,
2007 8:52 PM: 
> >     return ( ((maindiv2 + 2) * (maindiv1 + 2) *
> > CONFIG_SYS_CLK_FREQ) / ((prediv + 2) * (1 << ps))); }
> > 
> 
> 
> I think I see what the problem is but I'm not sure how to fix it in
> uboot. 
> When I multiply 450 and 14745600, I get a number greater than 32 bits
> and the MSB is missed. 

You could rearrange your formula:

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

The compiler should do the calculation from left to right.

Regards,
Martin





More information about the U-Boot mailing list