Creating a 1-microsecond software timer for the HCS12 processor

I'm using the MC9S12DB12B proceesor for an application, and I need to create some type of software-based timer with a 1-microsecond granularity for measuring how much time my code spends executing each of the tasks over a 1-second interval (for processor usage purposes).

I have a "TaskTimer" variable based on the RTI ISR which runs at a 1 millisecond rate (using an 8 MHz system clock). I use this variable for determining when to execute each of my tasks in the main task control loop.

However, 1 millisecond is too slow to capture how much time is spent within each individual task. I'm assuming that a timer with a 1-microsecond granularity would be able to actually capture task execution time.

I was looking at the Enhanced Capture Timer (ECT), but that doesn't seem to be the right application.

Any suggestions on what feature I could use, and on what the most effective way to set it up would be?

Assuming it is just a temporary development requirement, here is one approach that you could use:

If you have some output port pins available, you could assign one pin for each task you wish to monitor. Then force the relevant output pin high at the beginning of the task, clear it at the end. Use a 'scope on the pin to measure the duration of the pulse.