Bucket = 0.1 ∗ ((3600 ∗ 1767) / (667 ∗ 50)) = 19.07406
The value to enter in the bucket register should be set as:
Bucket Register = 19.07406 ∗ 2^24
The value to set the bucket register is therefore:
High word = 0x000013; Low word = 0x12F5CA
And I get vvvvery close to what the answer should be; 0x000013 and 0x12F598.
I'm losing precision with the bSum variable which has a decimal point after the calculation, but I can't change bSum to a double/float as the compiler throws an error about the >> operator. I'm guessing that I'm following the datasheets workings too literally and there is a way to bypass the multiplication by 224?
What can I do?
Backstory: I need to write two 24 bit words to a MAX78615 which are combined to form a 48-bit fixed-point number with 24 bits for the integer part and 24 bits for the fractional part. Here is the part in the datasheet (bottom of page 31)
jurs:
So why do you think that 19.07406 ∗ 2^24 is 0x1312F5CA and not 0x1312F598?
0x1312F598 is correct (integer rounding omitted).
headslap well now you mention it, I just did the maths, and it checks out... I was foolishly following the datasheet and realised that I didn't have the same value using my code so figured something was wrong.
Thanks for pointing out that I shouldn't blindly accept what a datasheet says, especially a Maxim one...