1
\$\begingroup\$

I am confused about how to configure an ATmega16A microcontroller to use an external clock instead of the internal one. I do not know whether I should set up the last bit as 0 or 1 for CKSEL in crystal mode. Why are there three different values given for this last one? Is there any reason or I can choose any one?

Table 8-3 from ATmega16A datasheet

Image source: Microchip (Atmel) ATmega16A datasheet

\$\endgroup\$
6
  • 2
    \$\begingroup\$ What do you mean by "the last bit"? CKSEL1 or CKSEL0? \$\endgroup\$
    – asdfex
    Commented May 13, 2023 at 16:25
  • 1
    \$\begingroup\$ Muhammad Hamza Farooq - Hi, Please remember the site rule which requires that when a post includes content (e.g. text, image, photo etc.) copied or adapted from elsewhere, that copied content must be correctly referenced. As a minimum, the source webpage or PDF etc. should be linked (references for books / articles should include title, author(s), publisher, edition, page numbers etc.). In order to help you, I found what I believe to be the source PDF link in this case and added it for you. For the future, please remember it's your responsibility to do that :) Thanks. \$\endgroup\$
    – SamGibson
    Commented May 13, 2023 at 16:43
  • 1
    \$\begingroup\$ You are asking about how to set it to external clock, but are pointing to which crystal options you should set. Those are two separate things. Either you set the AVR to use external clock or you set the AVR to use external crystal. Which is it what you want? \$\endgroup\$
    – Justme
    Commented May 13, 2023 at 16:53
  • 1
    \$\begingroup\$ @asdfex The CKSEL0. The least significant bit. \$\endgroup\$
    – kam1212
    Commented May 13, 2023 at 22:17
  • 1
    \$\begingroup\$ Doesn't table 8-4 in the spec sheet give the details of that? \$\endgroup\$
    – sai
    Commented May 14, 2023 at 5:24

1 Answer 1

1
\$\begingroup\$

The last bit of the CKSEL is used to setup the rising time for the clock as shown below from the ATmega16A datasheet. This can be used in the combination with the SUT bits to set up the rising time accordingly. enter image description here

Image source Atmega16A datasheet.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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