Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
12 years, 11 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;
}