I'm working on MC9S12XDT512 controller and i'm in particular dealing with timers. My requirement is that i need to measure how long my signal from the proximity sensor is ON and how long it is OFF. I've tried with the 16 bit TCNT register but i'm getting only the time when i my sensor detects an obstacle. Does using a periodic interrupt timer help? How do i use it?