Remove Your Arduino’s External Oscillator To Gain A Free Pair Of IO Pins


[Mark] from SpikenzieLabs was wrapping up a project using an Arduino the other day and found himself in need of a few more I/O pins. He could have added extra circuitry to the project, but he decided to see if he could gain a few pins by removing a few components instead.

He put together one of his Minuino boards, but rather than installing the crystal and its associated capacitors, he added a couple of pin headers in their place. It’s well known that the internal clock on the chip is not as precise as a crystal, but [Mark’s] project was not that time sensitive, so he had no problem sacrificing the oscillator for a few extra pins.

With his new I/O pins in place, he merely needed to tell the ATmega chip which clock it should be using, and he was well on his way. While this might not be the best solution for all projects out there, if you are building something that values pincount over precision, this hack is for you.

Check out the video below to see [Mark’s] hack in action.

[via HackedGadgets]


30 thoughts on “Remove Your Arduino’s External Oscillator To Gain A Free Pair Of IO Pins

      1. The only thing which makes a difference from the MiniDuino to the Atmel is the board. I mean, it is even socketed. Just pull it out, place on the board, done. Not even a need to build the whole Arduino board.

    1. Because he had the minduino laying around and this could help drive sales?

      Cool idea. I would think of it when working with the bare chip but it never would have come into my head as a possible solution when using a prepackaged dev board.

    2. Why doesn’t everyone just use an AVR and not an Arduino? Oh, because Arduinos are very easy to use.

      I lay out my own boards for Atmel’s SAM3 ARM chips and program them myself – but I still have a few arduinos lying around because they’re easier when all I need to do is blink some lights.

    1. Internal RC oscillator is specified up to 8MHz, but in reality it can be calibrated to run at up to 12MHz. V-USB has code that does this.

      HaD, please, work on your terminology. ATmega can be configured to run off an external clock, but it never was used here. The oscillator was and still is internal. He had originally an internal oscillator with external crystal. Then he switched the configuration to use the internal calibrated RC oscillator and removed the crystal, thus freeing 2 more pins for I/O. But crystal != oscillator. It’s only a part of it that defines frequency.

      Still breaking my head, since when this is news, but nevermind.

  1. Heh, just the other day I scrounged some parts in the lab and built up one of those Minuino boards Mark gave me in New York. I actually didn’t have through-hole 16MHz crystal and had to pull one off another dead board…should have thought of this idea!

    As an aside…the PCB is crazy thick, feels so weird…

  2. Does the arduino ide still work for loading code onto it? Aside from adjusting the clockspeed, I know that the internal oscillator isn’t recommended for serial communication because it can drift with temperature.

    1. You also take a pretty big hit in clock accuracy by using the internal oscillator versus an external crystal or even a resonator. Thats what is nice about the Teesnys. Paul used a high quality crystal and the trace lengths are optimized for the crystal. This means a very stable oscillator and it shows in his frequency measurement sketch.

      1. hehe! XD he’s right, its a catch 22 of AVR’s …

        its that way with several features of the device assuming you dont own a dev board with all programming methods in place.

        ICSP enable (if u own only ICSP programmer)
        JTAG enable (if u own only jtag programmer)
        clock-selection (if you dont own any crystals…lol)
        bootloader (if u dont own any programmers at all)

        plus the reset setting we are talking about!
        did i miss any catch 22’s ??? lol theres too many, oh wait, BOD if ur dev board is 3.3v with a 3.3or5 volt capable chip.

        BUT FEAR NOT!
        HackADay will help you sort it all out using search “unbrick AVR” and “unbrick” all your AVRs you have :)

        PPS: as for the chicken and egg situation of only HAVING one AVR, you can reverse engeneer the code and write x86 dos executable to use parallel port on old computer, er, i mean, port Arduino to x86, big project :P

        or with the addition of a few logic chips, use a “spare” IDE cable as a parallel port instead and write windows 2k/xp code :) muuuuch better
        THAT you can search HAD for “IDE stk200”
        but make it more then 8 bits instead of 4 bits to mimic standard LPT port wirings. IDE is 16 bit.

    1. Unnecessary.

      External oscillators are often required if you want to do software USB (and don’t want to overclock), use the fast capabilities of your chip (16MHz), need an accurate clock for rock solid high speed serial transfers, or are doing any sensitive timing applications (and this does not include building clocks where a RTC is often a better option).

      I’ve only really needed an external oscillator once. Plus using the internal oscillator, the clock div option, and a few other tricks you can get your power consumption down really low.

    1. It provides you the option to improve it. 9600 baud gives a 0.2% error rate with a 16MHz clock as provided on the board. The internal RC oscillator can be configured down to 7.3728MHz giving you a 0% error at at any standard board rate.

      It’s quite stable too.

    1. That’s the effect of the cargo cult that Arduino is causing. People don’t know Atmel from AVR, Arduino from microcontroller, resonator from oscillator and now they have discovered fuse settings. Oh boy, what they will think of next!

  3. Good idea, however the video should have gone in to a little more “arduino” detail here.

    How do I set the fuses using the Ardiuino IDE, etc.

    How do I reconfigure the IDE so that I can use these additional two pins.

    1. “How do I set the fuses using the Ardiuino IDE, etc.” You can’t. Arduino is strictly bootloader, and a bootloader cannot change fuses.
      “How do I reconfigure the IDE so that I can use these additional two pins.” The same way you SHOULD use the other pins. With the correct registers.

      1. I don’t think this is entirely correct.

        “You can’t”
        Last time I used the burn boot loader option in the IDE the fuses were also set. I understand they are referred to from the board.txt file and set. Something here would just need to be modified depending on the chip used.

        “Arduino is strictly bootloader”
        There is a lot more to Arduino than the bootloader. Libraries, IDE, etc.

        “the same way you SHOULD use the other pins. With the correct registers.”
        Isnt the whole point of the arduino ide/libraries to not have to use the port registers? Otherwise i’d just program straight avr-gcc.

  4. This did not work for me. I was able to upload the bootloader, but when I then went to upload a sketch to the chip via serial, the program always failed.

    What I did do that finally *worked* was as follows:

    I built a new version of the Optiboot, which is set to 8MHz OSC and 57600 baud. You can download it here:

    I added this board-type to the (aforementioned) boards.txt file with the following lines: Optiboot-Atmega8-16-BKGnoxtal

    The only modifications here are the “upload speed”, “f_cpu” and “low fuses”. In this configration, place the firmware file in the bootloaders/optiboot directory. This worked like a charm!

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.