cancel
Showing results for 
Search instead for 
Did you mean: 

Timer(32bit) Inputcapture

SA  V.1
Associate II
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 .

2 REPLIES 2
Stassen.C
ST Employee

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.

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();
}