TIM Rising and Falling edge timestamp measurement

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Kumaresh
Level 3
Level 3
10 questions asked 10 replies posted First solution authored

Hi,

Wanted to know whether is there a way to measure rising and falling edge timestamp from single TIM channel ?

Thanks,

Kumaresh

0 Likes
1 Solution
Kumaresh
Level 3
Level 3
10 questions asked 10 replies posted First solution authored

Hi,

The solution is not working. Added my implementation and output in detail could you pls have a look

I am trying to measure the duty cycle of the waveform with the time difference between rising and falling edge timstamp. The waveform has a period of 100 us and on time of 56 us. 

Implementation

We read the var diff which subtracts the previous and current timestamp measurement from GPR1 reg. This func is being called by master trigger pulse every 100 us

 

FS_Ph_Timestamp_prev = FS_Ph_Timestamp_current;
FS_Ph_Timestamp_current = (float)((GTM_Module_Ptr_temp->TIM[3].CH2.GPR1.B.GPR1)* 0.00000001);
diff = FS_Ph_Timestamp_prev - FS_Ph_Timestamp_current;

O/P from above suggested configuration

Kumaresh_0-1656593249845.png

Thanks,

Kumaresh

View solution in original post

0 Likes
2 Replies
Yuva
Moderator
Moderator
Moderator
250 replies posted 250 sign-ins 100 solutions authored

Hello,

Yes, this can be supported by setting TIM[i]_CH[x]_CTRL.ISL to detect both the edges and configure GPRx_SEL/ EGPRx_SEL to store the TBU (timestamp) to GPRx.

Thanks.

0 Likes
Kumaresh
Level 3
Level 3
10 questions asked 10 replies posted First solution authored

Hi,

The solution is not working. Added my implementation and output in detail could you pls have a look

I am trying to measure the duty cycle of the waveform with the time difference between rising and falling edge timstamp. The waveform has a period of 100 us and on time of 56 us. 

Implementation

We read the var diff which subtracts the previous and current timestamp measurement from GPR1 reg. This func is being called by master trigger pulse every 100 us

 

FS_Ph_Timestamp_prev = FS_Ph_Timestamp_current;
FS_Ph_Timestamp_current = (float)((GTM_Module_Ptr_temp->TIM[3].CH2.GPR1.B.GPR1)* 0.00000001);
diff = FS_Ph_Timestamp_prev - FS_Ph_Timestamp_current;

O/P from above suggested configuration

Kumaresh_0-1656593249845.png

Thanks,

Kumaresh

0 Likes