To avoid the accumulation of conversion error, the count in timer driver
should use the same time unit as the hardware. BTW, your timer driver
has
to implement the up_alarm_xxx functions.
Unfortunately, 32.768KHz is a very common clock frequency and it
cannot be handled by the current logic. Without a massive overhaul of
the timing definitions, the only solution that I know is keep a RAM
copy of the time that has been corrected for the differences in precision.
Can you multiply the 32.768KHz clock to improve the precision (but not
the resolution)?
Or, perhaps, just scale the timer in software? The LSB is 30.517578
usec. Shifting the timer value by 9 left would result in an LSB of
15,625 which is exact.