AnsweredAssumed Answered

Input Capture module in pulse count example

Question asked by Lyen.Rum on Jan 16, 2016
Latest reply on Jan 17, 2016 by Lyen.Rum
Hello all,

In an external pulse count application, is it possible to capture Timer counts at fixed interval using input capture (IC) module while external input (TIM5_CH1) is driving timer time-base (through TI1F_ED).

I've also tried just storing TIM5->CNT at every RTC interrupt, but found some irregular counts. May be this irregularity is for other interrupts (of high priority) with LP Sleep implementations.

I request some advice on how to configure this capture module (if possible on STML151, clock tree attached). I've configured TIM_5 like this:

.........
.........

  /* Reset the CC1E Bit to configure CC1S bit of CCMR1 Reg */
  TIM5->CCER &= (uint16_t)~((uint16_t)TIM_CCER_CC1E);
  tmpccmr1 = TIM5->CCMR1;
  tmpccer = TIM5->CCER;
 
  /* TIM5 Input CH1 is selected to be connected to IC1. and reset the filter */
  tmpccmr1 &= (uint16_t)(((uint16_t)~((uint16_t)TIM_CCMR1_CC1S)) & ((uint16_t)~((uint16_t)TIM_CCMR1_IC1F)));
  tmpccmr1 |= (uint16_t)(TIM_ICSelection_DirectTI | (uint16_t)(0x00 << (uint16_t)4));
 
  /* IC Rising edge and set the CC1E Bit */
  tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC1P | TIM_CCER_CC1NP));

  /* Write to TIM5 CCMR1 and CCER registers */
  TIM5->CCMR1 = tmpccmr1;
  TIM5->CCER = tmpccer;
 
  //Input Trigger source TIM_TS_TI1F_ED: TI1 Edge Detector.
  TIM_SelectInputTrigger(TIM5, TIM_TS_TI1F_ED);
 
  //Slave Mode TIM_SlaveMode_External1: SMS=111
  TIM_SelectSlaveMode(TIM5, TIM_SlaveMode_External1);
 
  /* TIM5 enable counter */
  TIM_Cmd(TIM5, ENABLE);

Attachments

Outcomes