12 years, 5 months ago.

Timer for interrupts

Hi

Could you tell me what is the best method for measuring time between rise and falling period of interrupts? When I implemented Timer into my code it wasn't working. Below, is my code which increments the counter whenever there is a rise.

Thanks

include the mbed library with this snippet

#include "mbed.h"

void pulseLeft();
void pulseRight();
void pulseStop();

int countLeft = 0;   
int countRight = 0;
    
           
int main() {





 ir_rx0.rise(&pulseRight);
 ir_rx0.fall(&pulseStop);

   
    while(true);
 
}

void pulseRight()
{
    countRight++;

    printf("COUNT_RIGHT = : %d\n",  countRight);
    
    if(countRight == 32)  
    countRight = 0;
    
    


}
    

Be the first to answer this question.