Derek Fritz

Creating a 1-microsecond software timer for the HCS12 processor

Discussion created by Derek Fritz on Jan 26, 2009
Latest reply on Feb 6, 2009 by Carl Barnes
Hello,

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?

Thanks in advance.

Outcomes