Stm32f429 GPS PPS measuring
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-04-20 12:38 AM
Hi! I try to measure GPS PPS (pulse per second) duration by TIM2. Setting code:
TIM_TimeBaseInitTypeDef TimeBaseInitStruct;
TIM_ICInitTypeDef ICInitStruct;
TimeBaseInitStruct.TIM_Prescaler = 0;
TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_DIV1;
TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up;
TimeBaseInitStruct.TIM_Period = 0xFFFFFFFF;
TimeBaseInitStruct.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(PPS_IN_TIM, &TimeBaseInitStruct);
TIM_SelectInputTrigger(PPS_IN_TIM, TIM_TS_TI1FP1);
TIM_SelectMasterSlaveMode(PPS_IN_TIM, TIM_MasterSlaveMode_Enable);
TIM_SelectSlaveMode(PPS_IN_TIM, TIM_SlaveMode_Reset);
ICInitStruct.TIM_Channel = TIM_Channel_1;
ICInitStruct.TIM_ICPolarity = TIM_ICPolarity_Rising;
ICInitStruct.TIM_ICSelection = TIM_ICSelection_DirectTI;
ICInitStruct.TIM_ICPrescaler = TIM_ICPSC_DIV1;
ICInitStruct.TIM_ICFilter = 0;
TIM_ICInit(PPS_IN_TIM, &ICInitStruct);
TIM2 clk:180Mhz. In interrupt value of CCR1 stored in array. Result:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-04-20 2:59 AM
Hi malenko.maxim,
The description of the issue is not clear enough . Please share the hole Timer initialization code and related main function parts.Which input pin you are using (PA8 ? PE9?) and pin configuration ?. Have you configured the NVIC for timer interruption ? The hardware you are using and if there is any external connections ? -Hannibal- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-04-20 3:09 AM
I believe it is showing you the frequency and drift rate of the receivers local clock wrt the PLL clock.
What make/model GPS receiver are you using?Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-04-20 3:34 AM
GPIO setting:
#define PPS_IN_TIM TIM2
#define PPS_IN_TIM_Handler TIM2_IRQHandler
#define PPS_TIM_IRQn TIM2_IRQn
#define GNSS_PPS_GPIO GPIOA
#define GNSS_PPS_PIN GPIO_Pin_5
#define GNSS_PPS_PIN_SOURCE GPIO_PinSource5
#define GNSS_PPS_AF GPIO_AF_TIM2
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_PinAFConfig(GNSS_PPS_GPIO, GNSS_PPS_PIN_SOURCE, GNSS_PPS_AF);
GPIO_InitStructure.GPIO_Pin = GNSS_PPS_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_Init(GNSS_PPS_GPIO, &GPIO_InitStructure);
Full timer setting:
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);
RCC_TIMCLKPresConfig(RCC_TIMPrescActivated);
TIM_TimeBaseInitTypeDef TimeBaseInitStruct;
TIM_ICInitTypeDef ICInitStruct;
TimeBaseInitStruct.TIM_Prescaler = 0;
TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_DIV1;
TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up;
TimeBaseInitStruct.TIM_Period = 0xFFFFFFFF;
TimeBaseInitStruct.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(PPS_IN_TIM, &TimeBaseInitStruct);
TIM_SelectInputTrigger(PPS_IN_TIM, TIM_TS_TI1FP1);
TIM_SelectMasterSlaveMode(PPS_IN_TIM, TIM_MasterSlaveMode_Enable);
TIM_SelectSlaveMode(PPS_IN_TIM, TIM_SlaveMode_Reset);
ICInitStruct.TIM_Channel = TIM_Channel_1;
ICInitStruct.TIM_ICPolarity = TIM_ICPolarity_Rising;
ICInitStruct.TIM_ICSelection = TIM_ICSelection_DirectTI;
ICInitStruct.TIM_ICPrescaler = TIM_ICPSC_DIV1;
ICInitStruct.TIM_ICFilter = 0;
TIM_ICInit(PPS_IN_TIM, &ICInitStruct);
TIM_Cmd(PPS_IN_TIM, ENABLE);
TIM_ITConfig(PPS_IN_TIM, TIM_IT_CC1, ENABLE);
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = PPS_TIM_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 11;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
Test handler:
uint32_t debug[128];
uint16_t dbgCnt = 0;
void PPS_IN_TIM_Handler()
{
static uint32_t ccr = 0;
if (TIM_GetFlagStatus(PPS_IN_TIM, TIM_FLAG_CC1) == SET)
{
ccr = TIM_GetCapture1(PPS_IN_TIM);
debug[dbgCnt++] = ccr;
dbgCnt &= 0x7F;
}
TIM_ClearITPendingBit(PPS_IN_TIM, 0xFFFF);
}
I use Stm32f429 Discovery. GLONASS receiver MNP-M7, but if measure pulse from AGF3022C result exactly the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-04-20 4:00 AM
You see the saw tooth on your other equipment? The output is the same as what?
I don't see a specification for the rms error in the 1pps. I'm thinking it is not very tight. What clock drift and bias measurements is the receiver outputting with respect to the local clock?Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-04-20 4:24 AM
I also use Tektronix AGF3022C to generate PPS and got the same saw tooth in debug array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-04-20 8:55 AM
I can't explain why the AFG3022C would give you the saw-tooth profile.
What is clocking the STM32F429?I might try to replicate this with a Nucleo-144 F429ZI and an u-Blox M8N later.Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-04-20 1:11 PM
Ok, so had a F446 to hand, 180MHz, APB1/TIM2 running at ~90MHz, measuring 1PPS from u-Blox M8 receiver.
89998948
89998945
89998945
89998947
89998945
89998945
89998945
89998947
89998945
89998947
89998945
89998945
89998945
89998947
89998946
89998945
89998947
89998945
89998945
89998947
89998945
89998946
89998947
89998945
89998945
89998947
89998946
89998945
89998948
89998945
89998946
89998947
89998945
89998945
89998948
89998945
89998946
89998947
89998945
89998946
89998948
89998945
89998946
89998947
Varies perhaps 4 or 5 cycles, not saw-toothing over 70
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-04-20 10:41 PM
Reviewing the number of seen satellites and quality of reception might be helpful. The accuracy of the PPS will surely degrade with fewer satellites.
As a side note, I used to live in AT not far from the swiss border. When politicians met in Davos, GPS accuracy was always seriously degraded, almost unusable.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-04-21 3:36 AM
clive1, could you send me your setting code(including sysclk) on maximmalenko@mail.ru?
