0. These macros are not *exclusively* for writing to registers. They are general purpose macros for manipulating timer values
1. The whole calculation is done in 64-bit. You don't need 64-bit registers to do 64-bit calculations.
2. The result *IS* is 64-bit value (whether you want to accept that or not). If you cast it to 32-bit, you will not lose precision - you will lose the UPPER part of the value - the most significant part of the value!
3. If you want to cast the value to 32-bit, you first need to make sure that you will not lose the upper part:
if (result_64_bit <= UINT32_MAX)
result_32_bit = (uint32_t) result_64_bit;
else
error("result too large for 32 bits);Note that when counting micro-seconds a 32-bit value overflows after 1 hour 11.5 minutes