AnsweredAssumed Answered

4 inputs pwm on TIM4

Question asked by chechio.cesare on Jul 3, 2014
Latest reply on Jul 14, 2014 by Clive One
How change this function to read frequency and dutycycle of 4 different pwm signals?

void TIM4_IRQHandler(void){
    
  RCC_ClocksTypeDef RCC_Clocks;
  RCC_GetClocksFreq(&RCC_Clocks);
  /* Clear TIM4 Capture compare interrupt pending bit */
  TIM_ClearITPendingBit(TIM4, TIM_IT_CC2);
  /* Get the Input Capture value */
  IC2Value = TIM_GetCapture2(TIM4);  
  if (IC2Value != 0)
  {
    /* Duty cycle computation */
    DutyCycleB7 = (TIM_GetCapture1(TIM4) * 100) / IC2Value;
    /* Frequency computation 
       TIM4 counter clock = (RCC_Clocks.HCLK_Frequency)/2 */
    FrequencyB7 = ((RCC_Clocks.HCLK_Frequency)/2 /(IC2Value));    
  }
  else
  {
    DutyCycleB7 = 0;
    FrequencyB7 = 0;
  }
  }

Outcomes