rtarb41323 1 Posted June 29, 2015 Share Posted June 29, 2015 Greetings all! I'm trying to make a 10MHz oscillator that is phase-coherent with a GPS PPS signal from a GPS receiver that I have. I'm using the MSP432 launchpad to do this, but I'm not sure it has the speed to act as a 10MHz frequency counter. The general setup is simple: GPS PPS--------------- | -->VCO --> MSP432 launchpad --> DAC -- | | ----------------------------------------------------- Every 1 PPS, the MSP432 will count the number of pulses it receives from the VCO. If the pulses are more or less than 10,000,000, then adjust the VCO input voltage via the DAC. 1. I have two interrupts - one that triggers on the rising edge of the PPS pulse (so this interrupt will happen once a second), and a second that triggers on every rising edge of the VCO output (so this will trigger ~10,000,000 a second). I think I'm allowed to use two separate interrupts at the same time - how can I set the PPS interrupt as a higher priority over the VCO interrupt? Thank you for any help you can provide! -Rick Quote Link to post Share on other sites
oPossum 1,083 Posted June 29, 2015 Share Posted June 29, 2015 Use the VCO as an external timebase for the counter. Use the GPS PPS as a timer capture interrrupt. The ISR for the timer capture interrupt will subtract the current capture from the previous to determine the VCO frequency. The DAC can then be adjusted using that value and a suitable control loop such as a PID. Quote Link to post Share on other sites
rtarb41323 1 Posted June 29, 2015 Author Share Posted June 29, 2015 Thanks for your reply oPossum! --> Am I understanding your response, to say that I only need 1 interrupt to do this (and not 2 like I previously thought)? -Rick Quote Link to post Share on other sites
oPossum 1,083 Posted June 29, 2015 Share Posted June 29, 2015 Yes, only 1 interrupt. The PPS will trigger the interrupt and the timer capture register will hold the *exact* time count when the PPS input changed. Using timer capture eliminates the jitter cause by interrupt latency. abecedarian 1 Quote Link to post Share on other sites
rtarb41323 1 Posted June 30, 2015 Author Share Posted June 30, 2015 Thank you again oPossum for your help! I'm trying to read up on the MSP432 and its Timers, as it appears that Energia (my original programming IDE) does not have functions to use the individual timer functions that I need (for instance, using a Timer as a counter with an external input). Don't mean to pester, but a follow-up question to you (I have also asked this in the e2e forums at TI.com): When using the PPS trigger, let's say that I START counting on one PPS reception, then STOP counting on the next PPS reception, then START counting on the next... etc.... --> Will the timer/counter that I use be able to start counting immediately on the PPS interrupt, so that I don't potentially miss a pulse or two due to interrupt latency? Quote Link to post Share on other sites
B@tto 51 Posted July 1, 2015 Share Posted July 1, 2015 Hi, You just have do don't stop the timer, just reset the count. PPS signal -> interrupt store counter value reset counter do anything else PPS signal -> interrupt store counter value reset counter In fact it just depends on how you configure your timer : here just setup it to do not stop on interrupt. Quote Link to post Share on other sites
oPossum 1,083 Posted July 1, 2015 Share Posted July 1, 2015 The most accurate results will be obtained if the counter is never stopped or reset. The time interval is calculated by subtracting the previous capture from the current capture when the capture interrupt occurs. Refer to 17.2.4.1 (capture mode) and 17.2.2.1 (external clock source) of slau356a. void timer_capture_isr(void) { static int16_t previous_capture; int16_t const timer_capture = (int16_t)TAxCCRn; int16_t const error = timer_capture - previous_capture + 27008; previous_capture = timer_capture; // do something with error } Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.