Skip to main content
SA V.1
Associate III
August 10, 2023
Question

Timer(32bit) Inputcapture

  • August 10, 2023
  • 1 reply
  • 2203 views
STM32H745i Discovery kit :

In this board TIM2/5 are 16/32 bit  timers when am going to configure in cubeIDE there Prescalar is 16bit  . How can  i use 32bit timer ??  and in this board input pin terminations are very crucial  ?? Any help would be thankfull .

    This topic has been closed for replies.

    1 reply

    Stassen.C
    ST Employee
    August 10, 2023

    Hello SA V.1,

    Your Timers 2 and 5 are 32bits timers as you can see below:

    StassenC_2-1691655727020.png

    The prescaler on the other hand is 16bits and is there to divide your counter period if needed.

     

    Regards,
    Stassen

    To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
    SA V.1
    SA V.1Author
    Associate III
    August 10, 2023

    Bellow  is callback function but  IC_Value1  and  IC_Value2  bothn always 0 so program counter goes to error handler  why happening like this ??TIC.jpj.png

    void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
    {
    if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_2) // if interrput source is channel 1
    {
    if (Is_First_Captured==0) // is the first value captured ?
    {
    IC_Value1 = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_2); // capture the first value
    Is_First_Captured =1; // set the first value captured as true
    }

    else if (Is_First_Captured) // if the first is captured
    {
    IC_Value2 = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_2); // capture second value

    if (IC_Value2 > IC_Value1)
    {
    Difference = IC_Value2-IC_Value1; // calculate the difference
    }

    else if (IC_Value2 < IC_Value1)
    {
    Difference = ((0xffffffff-IC_Value1)+IC_Value2) +1;
    }

    else
    {
    Error_Handler();
    }