cancel
Showing results for 
Search instead for 
Did you mean: 

Can STM32F103RB-Nucleo even do PWM Input Capture?

john doe
Lead
Posted on July 26, 2017 at 02:59

Cannot get it to fire the IC Capture interrupt, and the macro that decodes the PWM Pulse finished interrupt might be broken becuase all running timers seem to be  sent a handle to that callback. htim->Instance TIM2 gets a callback, when i tried.

LED shows the PWM ringing away from TIM1 but TIM2 never gets the IC Capture callback

STM32CubeMX 4.22

STM32Cube_F1_1.6

Timer 1:

prescaler 7199

period 9999

pulse 5

Output to pin PA11

Timer 2:

prescaler 0

period 65535

input TI1FP1 on PA0

The CubeMX application generates:

    /**TIM2 GPIO Configuration    

    PA0-WKUP     ------> TIM2_CH1

    */

    GPIO_InitStruct.Pin = GPIO_PIN_0;

    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

    GPIO_InitStruct.Pull = GPIO_NOPULL;

and GPIO_MODE_AF_INPUT is the same as MODE_INPUT

DIER is set for interrupt on CC1IE and CC2IE

can't get CCR1 to set

Registers:

AFIO->MAPR:  0x02000000

GPIOA->CRL:  0x4434AA44

GPIOA->CRH:  0x8884B444

GPIOA->IDR:  0x0000F7DE

GPIOA->ODR:  0x0000A000

GPIOA->BSRR: 0x00000000

GPIOA->BRR:  0x00000000

GPIOA->LCKR: 0x00000000

TIM1->CR1:   0x00000001

TIM1->CR2:   0x00000000

TIM1->PSC:   0x00001C1F

TIM1->ARR:   0x0000270F

TIM1->RCR:   0x00000000

TIM1->DIER:  0x00000010

TIM1->SMCR:  0x00000000

TIM1->CCER:  0x00001000

TIM1->CCMR1: 0x00000000

TIM1->CCMR2: 0x00006C00

TIM1->CCR1:  0x00000000

TIM1->CCR2:  0x00000000

TIM1->CCR3:  0x00000000

TIM1->CCR4:  0x00000005

TIM1->EGR:   0x00000000

TIM1->DCR:   0x00000000

TIM1->DMAR:  0x00000001

TIM1->CNT:   0x0000027B

TIM1->SR:    0x00000011

TIM2->CR1:   0x00000001

TIM2->CR2:   0x00000000

TIM2->PSC:   0x00000000

TIM2->ARR:   0x0000FFFF

TIM2->RCR:   0x00000000

TIM2->DIER:  0x00000006

TIM2->SMCR:  0x00000054

TIM2->CCER:  0x00000002

TIM2->CCMR1: 0x00000201

TIM2->CCMR2: 0x00000000

TIM2->CCR1:  0x00000000

TIM2->CCR2:  0x00000000

TIM2->CCR3:  0x00000000

TIM2->CCR4:  0x00000000

TIM2->EGR:   0x00000000

TIM2->DCR:   0x00000000

TIM2->DMAR:  0x00000001

TIM2->CNT:   0x00005821

TIM2->SR:    0x00000059
1 REPLY 1
Posted on July 26, 2017 at 08:21

Good morning.!

The period of timer1 to give an pwm output is 80000000 fclocks (supose APB2 prescaler is 1 or 2 )

The period that Timer 2 can measure is at most 65536  fclocks (supose APB1 presc is 1 or 2)

You can catch PWMs with cycle period less than tim2 max count period. ((presc+1)*reload val)