# define BUS (48000000)
# define PRE (64)
# define CLK ( BUS / (10000*PRE) )
main()
{
unsigned int A;
A= CLK;
}
******************************************
result: A=CLK= 62411, why? Help,Thank you!
Solved! Go to Solution.
(int)10000 * (int)64 = (int)0xC400 = (int)-15360
(long)48000000 / (int)-15360 = -3125
(unsigned int)-3125 = 0xF3CB = 62411
Some UL's or typecasts are missing, try this:
# define BUS (48000000ul)
# define CLK ( BUS / (10000ul*PRE) )
(int)10000 * (int)64 = (int)0xC400 = (int)-15360
(long)48000000 / (int)-15360 = -3125
(unsigned int)-3125 = 0xF3CB = 62411
Some UL's or typecasts are missing, try this:
# define BUS (48000000ul)
# define CLK ( BUS / (10000ul*PRE) )
Thanks you very much! Best wishes for you!