Keil Logo

µVISION DEBUGGER: 8051 CLOCK Speed Vs XTAL Speed


Information in this article applies to:

  • µVision Version 2.06

QUESTION

How can I configure the xtal speed, clock speed, and calculate the execution time of sections of my program using the µVision Debugger?

ANSWER

For each simulated 8051 derivative, VTREGs are defined for the XTAL speed and the CLOCK speed.

The CLOCK speed is the speed of the internal instruction clock. It is derived by dividing the frequency of the external oscillator (XTAL) by an integer value (usually 12).

You may change either of these values and the other is automatically adjusted.

On a standard Intel 8051FA, for example,

XTAL = 12000000

automatically sets CLOCK to 1,000,000 which is 12,000,000 / 12. Other microcontrollers may have a different divisor for the instruction clock.

The µVision debugger includes a system variable named states which contains the number of instruction cycles that have passed. So, to calculate the time it takes a block of code to execute, you must know the starting and ending state values. Then, take the difference and divide by the CLOCK value.

For example:

Execution_Time = (End_State_Value - Start_State_Value) / CLOCK;

Last Reviewed: Friday, February 12, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.