Creating a 1-microsecond software timer for the HCS12 processor

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Creating a 1-microsecond software timer for the HCS12 processor

1,623 次查看
aceshigh
Contributor I
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.
标签 (1)
0 项奖励
1 回复

306 次查看
mculater
Contributor III

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.

Best regards,
Carl Barnes
www.technologicalarts.com
A full line of HC11/HC12/HCS12 hardware.
Evaluate * Educate * Embed

0 项奖励