AnsweredAssumed Answered

PWM Input Capture vs. EXTI+TIMx->CNT differing values

Question asked by john doe on Aug 18, 2017
Latest reply on Aug 18, 2017 by john doe

I'm having a really fun time learning this stuff!

I have my WWVB decoder working with EXTI and TIM2 free running .  As a learning exercise, I was trying to use the PWM Input Capture method.


TIM2 prescaler is (timer clock/1000) -1 in both situations, and ARR 0xFFFFFFFF


With the PWM Input Capture method, I'm using this formula to determine pulse width:

abs(*(uint32_t*)&TIM2->CCR1 - *(uint32_t*)&TIM2->CCR2);


With the EXTI+TIMx method, here's how I'm measuring it:

    if (GPIO_Pin == WWVB_IN_Pin)
        GPIO_PinState pinState = HAL_GPIO_ReadPin(WWVB_IN_GPIO_Port, WWVB_IN_Pin);
        if (pinState == GPIO_PIN_SET)
                    pulseStart = htim2.Instance->CNT;
        if (pinState == GPIO_PIN_RESET) {
                    pulseEnd = htim2.Instance->CNT;
                    pulseReceived = 1;


I get vastly differing values [using two boards sharing same input signal] between the two methods.  The PWM Input Capture method has very much shorter measured pulse time.  Am I getting it wrong, or is that normal?  Shouldn't the values measured be closer?