cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G431

omid hamdi
Senior

I USED 6 PCS TIMER IN ENCODER MODE NEED ON SOFTWARE 64BIT POSITION

I USED CHECK DIR AND SR BIT FOR TRAKING

BOUT SOME TIME CHANGE DIR FAST AND I MAKE MISTAKE AROUND 65535

HOPE ANY ONE CAN HELP HOW TO RESOLVED

void tasktim2(void)

{

 uint16_t b2;

if ((TIM2->SR & 0x00000001) == 0x00000001)

{

  TIM2->SR = 0;

   if ((TIM2->CR1 & 0x00000010) == 0x00000010)

  {

  comandpulse_parameter1.count--;  

 }

 else 

 {

   comandpulse_parameter1.count++;

 }

  b2 = TIM2->CNT;

  comandpulse_parameter1.highposition = (comandpulse_parameter1.count * (65536)) + b2 ;

 comandpulse_parameter1.BACKUP = b2;

}

}

0 REPLIES 0