2023-08-10 12:56 AM
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 .
2023-08-10 01:24 AM
Hello SA V.1,
Your Timers 2 and 5 are 32bits timers as you can see below:
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.
2023-08-10 03:04 AM
Bellow is callback function but IC_Value1 and IC_Value2 bothn always 0 so program counter goes to error handler why happening like this ??
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();
}