How to turn on and off TIMER1 and Read timer value to measure duration (MPLAB IDE)
I was trying to write a program to measure how long (microseconds) a pin has been set to HIGH. But failed many times now. So I was bound seek help here.
I tried starting and stopping the TIMER1 and reading value from TIMER1 register. Used the following functions in MPLAB XC8 compiler - TMR1_StartTimer(void), TMR1_StopTimer(void), TMR1_ReadTimer(void).
I still couldn't get the output.
I came across this issue while I was trying to measure distance with sonar sensor HC-SR04.
I am using MPLAB XC8 compiler, PIC16f15344 microcontroller and the CURIOSITY LPC board.