Hi,
There could be several ways to achieve this. You can do a SW poll of the external pin and start/stop some internal timer upon high/low level detection. You can also connect a switch to pin which enable interrupt upon edge detection. Within such interrupt you can again start/stop internal timer.
You can also use the eTimer module in various modes, like Gated mode. In this mode you will count internal clock when external input is high (or low). Or you can use eTimer’s Capture feature to save value of internal counter at the time of external input high/low edge detection.
BR, Petr