Hi Everyone,
I am currently working on a project which requires measuring the frequency of a signal in the range of 40KHz-170KHz, with reasonably high accuracy. Any clock/timer with more than 48Mhz should provide sufficient accuracy. I have been experimenting with the MSP460F5171 as the timer_d module of this chip is capable of these speeds while still quite low power. However, I seem to be having an issue with accuracy which I believe is due to jitter and would like to know if this is a hardware limitation or if the module is configured incorrectly.
The setup:
Using timer_d in capture mode and free-running mode at 64MHz I am able to get the time between rising edges for a given number of rising edges, then observe the time taken to do so. For example I have been counting the total time taken for 23 rising edges from a 90KHz square wave signal from a function generator.
The Problem:
The time take for each cycle (23 rising edges) appears to variate by around 20 - 50 of the 64MHz clock cycles. The input is quite stable, I have confirmed it is stable by measuring it on an oscilloscope and checked it on another (non TI) microcontroller which has successfully measured the same period with a maximum variation 2 (48 MHz) clock cycles. I require the variation to be less than 8 clock cycles out.
After measuring 5 cycles (of 23 rising edges) in a row, I got the following values: 14680, 14689, 14674, 14678, 14693 which shows a variation of 19 (14693 - 14674) 64MHz clock cycles. 19 clock cycles variation in such a small time is too much.
Is this some sort of jitter problem? Is the module not able to do the required accuracy since it is reliant on an oscillator internal to the timer_d module? Any ideas if its possible to fix this issue?
I have initialised the module with the following:
P3DIR &= ~BIT2; // TD0.0 input
P3SEL |= BIT2; // TD0.0 option select
TD0HCTL1 = CALTDH0CTL1_64; // Get the 64 Mhz TimerD TLV Data
TD0CTL0 = CNTL_0 // 16-bit timer
+ ID_0 // Divide by 1
+ MC_0; // Halt timer until init is complete
TD0CTL1 |= TDCLKM_1; // TD0 clock = Hi-res local clock
// FREE RUNNING MODE (TDHREGEN = 0)
TD0HCTL0 = TDHFW // Fast wake-up mode.
+ TDHD_0 // Set divider to 1
+ TDHM_0 // Multiply by 8
+ TDHEAEN // Enhance accuracy
+ TDHEN; // Enable Hi-Res
// Dual Capture mode.
TD0CTL2 |= TDCAPM0;
TD0CCTL0 = CAP // Capture mode
+ CM_1 // Rising edge
+ CCIS_1
+ CCIE; // Enable local interrupt for Timer TD0.0
// Start the counter (continuous mode).
TD0CTL0 |= MC_2;
Any insights would be greatly appreciated.
Thanks,
Jake