0
\$\begingroup\$

I'm trying to design an 8051 microcontroller circuit which uses timers/counters, and the circuit I'm using for inspiration uses a clock generated using the XTAL1 and XTAL2 pins of the IC, shown in the picture.

What I don't understand is why this clock is necessary for using the counter function of the IC, and where the output of the clock goes. I tried using a logic probe to test where the clock was outputted but couldn't figure it out.

\$\endgroup\$

migrated from stackoverflow.com Feb 10 at 22:07

This question came from our site for professional and enthusiast programmers.

  • 1
    \$\begingroup\$ Usually when a microprocessor has pins for connecting a timing crystal like this they're for generating the clock that entire microprocessor runs on it. That is, the crystal determines the speed the CPU runs at. \$\endgroup\$ – Ross Ridge Feb 10 at 19:23
  • \$\begingroup\$ MCUs are synchronous logic - the clock is the "metronome beat" on which everything happens, most things taking many beats to accomplish. Your timers effectively divide this clock by counting cycles of it... \$\endgroup\$ – Chris Stratton Feb 10 at 22:50
  • \$\begingroup\$ The crystal might be optional for some microprocessors that have internal clocks, which is why you can sometimes see reference circuits with and without them for the same IC, but these oscillators are too imprecise as a frequency reference, so you can derive neither system clocks nor protocol timings from them — all they are good for is to run the CPU at roughly the correct speed. \$\endgroup\$ – Simon Richter Feb 10 at 22:53
  • \$\begingroup\$ it is unclear what you are designing ..... what is your understanding of the 8051? .... what do you think that it is? \$\endgroup\$ – jsotola Feb 10 at 23:09
3
\$\begingroup\$

The MCU processor requires a clock to do (almost) anything. Aside from perhaps the RST input which is probably partially asynchronous, everything happens after some number of clock edges.

None of the code will run without a clock, so, for example, the timer module cannot be set up without a clock and some code.

The 8051 is a rather old microcontroller and requires an external clock (either a pulse train or there is an internal oscillator which can use a bare crystal). Some relatively newer processors may have an internal RC clock, as an option or perhaps as the only clock source.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.