cancel
Showing results for 
Search instead for 
Did you mean: 

Hello, I need to count the rising edge of two waveforms individually by setting flag and use Timer as my interrupt with 100KHZ frequency. Each time my counter needs to increment . when my flag become equal to zero i need to reset my counter.

Lchal.1
Associate II

can anyone help me how to code please . Actually this my first project.

thank you

2 REPLIES 2
TDK
Guru

A 100 kHz interrupt is a bit fast. You might starve the CPU of resources.

Counting edges can be done with the timers.

One place to start is with HAL examples.

If you feel a post has answered your question, please click "Accept as Solution".

i am already generating two waveforms with some dealy . But should i use Input capture method to capture the values at rising edge at each pulse and need to count for every rising edge using interrupt.

i am going to set my flag as start counter=1;

if(start counter==1) // if my flag is equal to 1 going to start the counter at each rising edge

{

do

{

uint16_t count = __HAL_GET_COUNTER(&htimx); // these lines of code do i need to add in my IC calling function or in while loop

count++;

}while(start counter!=0) // if my flag is equal to 0 reset my counter

count =0; // i need to reset my counter

}

should i need to to measure input capture value of both rising edges also because i need to calculate the phase angle between two waveforms. If so were i need to add my code to measure input capture values. if my code has any mistake can you please suggest me i am confused of it.

Thank you