Harmony 3 Timer (TMRX) Component Period Calculation Precision?
This might be an easy one due to me not understanding the intricacies of the hardware timers, but I've got a bit of a head scratcher. I'm using Harmony Configurator 3.5.0, Core 3.7.2. (Latest I see in my content manager.)
I've added a TIME (System Service) component, with the intent to use it to satisfy a USB Host Layer component. To satisfy the TMR dependency of TIME, I've added a TMR2 component, just to pick a type B timer to use in 16-bit mode.
My PBCLK at 96 MHz, (DIV1 from my SPLL), so I've selected the 1:4 prescaler for my TMR2. Correctly, Harmony 3 displays my timer clock frequency as 24 MHz. Setting my Timer Period to 1, the period it generates for it is 23,999. I found this odd, as I'd be sure it should be 24,000. I thought, perhaps I'm just confused, because of when the TMR actually resets the counting and so forth.
Clicking over to my TIMER service, with a Tick Rate of 1 ms. there, it actually tells me my achievable tick rate resolution (ms.) is 0.999958341735. Okay, that's close, but it's not exact, so I clicked back over to the TMR and played with period there. I found that if I set the period to 1.000042, (it'd change it in the box to 1.000041, but) it would adjust the period register to exactly 24,000. Clicking back over to the TIME component, sure enough the available resolution is 1.0 ms. Well now I'm very confused.
So either there's a floating point inaccuracy in a conversion here somewhere (or maybe an int rounding/flooring), or I'm definitely not understanding the hardware like I thought I did.
Just for S&Gs, I went back to TMR2 and typed the period to be 1.000041 ms (the same value that was displayed when I entered the 42 before,) and it rolls that clock period down to 23,999!
Thanks in advance!
Other details about my setup:
PIC32MX470F512L w/ 8 MHz XT (It's the PIC32 USB STARTER KIT III)
MPLAB X 5.40