AnsweredAssumed Answered

Shouldn't HAL_TIM_IC_Start_IT() set TIMx->CCER?

Question asked by john doe on Aug 6, 2017
Latest reply on Aug 7, 2017 by john doe

STM32L476-Nucleo board, with jumper wire from PA7 to PA0. Attempting to learn PWM Input Capture.

GPIOA->AFR[0]:  0x20007701    00100000000000000111011100000001
  PIN  0: TIM2_CH1
  PIN  1:  -
  PIN  2: USART2_TX
  PIN  3: USART2_RX
  PIN  4:  -
  PIN  5:  -
  PIN  6:  -
  PIN  7: TIM3_CH2

 

TIM3 free running, no prescaler, ARR 0x7FFF, pulse 0x15.
 

 


    HAL_TIM_IC_Start_IT(tim_baseHandle, TIM_CHANNEL_1);
    HAL_TIM_IC_Start_IT(tim_baseHandle, TIM_CHANNEL_2);

 

yields

 

TIM2->CCER:     0x00000020    00000000000000000000000000100000
  CC1E   : Capture disabled
  CC1P/NP: Non-inverted/rising edge
  CC2E   : Capture disabled
  CC2P/NP: Non-inverted/both edges
  CC3E   : OC1 is not active (OCx=0, OCx_EN=0)
  CC3P/NP: OC1 active high
  CC4E   : OC1 is not active (OCx=0, OCx_EN=0)
  CC4P/NP: OC1 active high

 

and

TIM2->CCR1:     0x00000000    00000000000000000000000000000000
TIM2->CCR2:     0x00000000    00000000000000000000000000000000

 

 

but, after initialization, if I

*(uint32_t*)&TIM2->CCER |= (TIM_CCER_CC1E | TIM_CCER_CC2E);

 

I get

TIM2->CCER:     0x00000031    00000000000000000000000000110001
  CC1E   : Capture enabled
  CC1P/NP: Non-inverted/rising edge
  CC2E   : Capture enabled
  CC2P/NP: Non-inverted/both edges
  CC3E   : OC1 is not active (OCx=0, OCx_EN=0)
  CC3P/NP: OC1 active high
  CC4E   : OC1 is not active (OCx=0, OCx_EN=0)
  CC4P/NP: OC1 active high

 

and

TIM2->CCR1:     0x00007FFE    00000000000000000111111111111110
TIM2->CCR2:     0x00007FE9    00000000000000000111111111101001

which, coincidentally, is the duty cycle of the pulse output on TIM3.

 

 

it would seem that either i am doing something wrong, or TIM_CCxChannelCmd(); is.

STM32CubeMX 4.22.0 and STM32Cube_FW_L4_V1.8.1

ARR of TIM2 may vary from .ioc file. otherwise, everything is as-generated.

Attachments

Outcomes