16

Your toolchain is not broken. In the ATTiny804/1604 datasheet, page 77, it shows the CPU clock is divided from the 20/16 MHz oscillator by a prescaler (the ATTiny1614 datasheet shows the same clock prescaler in page 80. So it's a feature found in both tinyAVR 0/1 microcontrollers). Source: Microchip ATTiny804/1604 datasheet, fair use. The datasheet says... ...


13

Why is there a clock in my arduino? Because that is how computers and microcontrollers, etc, work. With a 16mhz clock, each line of my program will take 1/16000000 second, right? No. even a very very big line will only take 1/16000000 of a second ? No. The clock defines at what speed the machine code instructions are fetched from memory and ...


13

The ceramic resonator in yellow is connected to the main MCU, and the crystal in red is connected to the other MCU. USB requires tighter tolerances than is available from a resonator therefore a crystal must be used instead.


10

Not answered in @Majenko's post: Yes, with a 8MHz clock, each line will take the double of the time. Unless the line waits for something that is not clock driven - e.g. external input. In addition to @Majenko's answer, a CPU has a clock to ensure the instructions are complete, before the next step starts. A CPU is made out of lots of transistors (I found a ...


10

The clock speed selected will affect both delay*() and millis()/micros() as well as the functions in <util/delay.h>, therefore you must use the target system's correct clock speed if you are using any of these functions. This can be easily done by editing boards.txt and copying an existing entry for the Uno and changing the value of the f_cpu parameter ...


9

Officially, no. Practically, often but not always. If I follow the datasheet to the the letter, this configuration should not work. BUT... After some test, it did work. The data sheet does not say that it "should not" work, it says that it is that the part is not qualified for operation at 16 MHz below some voltage higher than you want to use. That ...


7

There's no hardware reason (as far as I'm aware) that you couldn't run a suitable Arduino at 20 MHz. You'd run into minor timing inaccuracies in software though, as the standard Arduino configuration apparently works best if the clock speed is either 8 or 16MHz. I suspect this is largely for historical reasons. Early Arduino boards were based on chips which ...


7

This outputs 8 MHz on pin 9: #ifdef __AVR_ATmega2560__ const byte CLOCKOUT = 11; // Mega 2560 #else const byte CLOCKOUT = 9; // Uno, Duemilanove, etc. #endif void setup () { // set up 8 MHz timer on CLOCKOUT (OC1A) pinMode (CLOCKOUT, OUTPUT); // set up Timer 1 TCCR1A = bit (COM1A0); // toggle OC1A on Compare Match TCCR1B = bit (WGM12) |...


5

Do I need an oscillator installed just so I can wake it it up and tell it to not use an oscillator? Yes, yes you do. Pick up a 8-16MHz crystal (not an oscillator) and two 15pF capacitors and use very, very short wires to connect them to the chip as shown in the "System Clock and Clock Options" section of the '328P datasheet. You will then be able to ...


5

The default configuration of these chips, as they come from the factory, is to use their internal 8 MHz RC oscillator downscaled at 1 MHz. So you do not need any extra oscillator to program them. Once you program the chip the first time, if you configure it to use an external resonator/oscillator, then you do need to have that attached in order to reprogram ...


5

No, you won't be able to build a 16 MHz clock signal using a 555 timer. That's far beyond the 555 capabilities (see N.B.). If you could squeeze out of the 555 a mere 1 MHz (which I seriously doubt), the clock stability and jitter would be so bad that it won't be usable but for simple sketches not requiring any timing accuracy. At that point, you would be ...


4

Sharing a crystal between multiple devices is a very bad idea. The crystal is only a piece of the oscillator, the rest of it being a small bit of circuitry within the IC itself. Having multiple ICs connected to the same crystal will cause them to fight over who is driving it. The datasheet for the CH340T/R, which I was able to find in English, says the ...


4

You can, and I do. It's not technically an Arduino anymore, I guess. I made my own board, replacing a resonator on a board will require some fine soldering, but it is definitely possible. There are some gotchas: Anything time-related (e.g. millis() ) will be run faster than is should - 25% more millis() per second. Also, the bootloader expects 16mhz, so ...


4

It was a brownout fuse problem. Changing boards.txt from: atmega328bb.bootloader.extended_fuses=0x05 to atmega328bb.bootloader.extended_fuses=0x02 solved it for me (*). The chip and red LED now work at 3.01V (1xAA alkaline and 1xAA rechargeable) and 3.19V (2xAA alkaline). (*) not sure why I had to invert the bits (0000 0010=0x02 versus 0000 0101=0x05)...


4

You can set the clock prescaler for that: void setup() { noInterrupts(); CLKPR = _BV(CLKPCE); // enable change of the clock prescaler CLKPR = _BV(CLKPS0); // divide frequency by 2 interrupts(); } This is explained in section 10.12 and 10.13 of the ATmega2560 datasheet. Of course, changing the clock frequency will mess with the time-...


4

I doubt if that would be fast enough. See my thread about connecting to a VGA monitor. Borrowing from that page, so as to not make a link-only answer ... For 640x480 pixels of active video you have something like this: Vertical Sync Let's start with the vertical sync pulses. In fact, we'll show how all the timing data can be derived from three figures: ...


4

If you are using an LED to indicate that your sketch is running, then that may be the problem. For example, if you have a fairly average red LED, it might have a forward voltage of 2.0v @ 20ma (refer to your spec sheet for your particular LED). Putting these values into the LED calculator, it would tell you that you need a 150 ohm resistor. You might have ...


4

A little test, not very scientific, but shows it runs fine on 3.3V - https://www.youtube.com/watch?v=If0eOa0Uj5I. Again, if you would like to stay withing the specification just use a "clock divider/2" and run your MCU at 8MHz if they have a 16MHz Crystal: clock_prescale_set(clock_div_2) http://www.nongnu.org/avr-libc/user-manual/group__avr__power.html


4

According to the datasheet you need 3.78V to run at 16 MHz, and 3.3V isn't that far off. I would be surprised, for example, if it stopped working at 3.77V, because that would mean that the operating at 3.78V was marginal. I have operated these chips out of spec, for example under voltage, or with a 24 MHz crystal. They seem to work. However I would guess ...


4

You can set the clock prescaler at run time. For example: #include <avr/power.h> void setup() { clock_prescale_set(clock_div_8); // etc... } More details in the documentation from avr-libc. Note that with this method your Digispark will still be overclocked when booting, so it might not be 100% reliable. But it will be overclocked only for ...


4

The easiest way is to use the settings: Tools > Board > Arduino Pro or Pro Mini Tools > Processor > ATmega328 (3.3V, 8MHz) The problem with that is the Pro Mini bootloader is 2kB and has a bug that causes an endless reset loop if you do a watchdog reset. The better option is to use https://github.com/MCUdude/MiniCore, which includes the Optiboot ...


4

Yes, you could use a 555. You can also go even simpler and use an RC network. Even simpler still is to use the 1MHz RC network built in​ to the chip. The main drawback of these methods, and the 555 particularly, is that of stability. Using a crystal and capacitors you can get very accurate timing at high frequencies. Using a 555 you can get ballpark timing ...


4

If it requires a crystal, as the ones in question clearly state, then obviously you need to connect a crystal (and load capacitors). Or use a ceramic resonator. Only those labelled as internal are internal. Everything else is external.


3

The ATMega328p is not rated to operate at 16 MHz on a 3.3v supply. In practice it may sometimes work, but cannot be considered reliable. The data sheet will show the actual clock rate vs. voltage tradeoffs, so there might be an intermediate value that is workable for you. The Arduino toolchain needs to know the CPU clock frequency for the serial baud ...


3

For your external source to be an SPI bus master, it has to be the only one generating the clock signal. Yet, calling SPI.transfer() also generates a clock signal from the Arduino; both devices are attempting to drive the clock line simultaneously, hence your problems. You have to bit-bang this or manipulate the SAM registers yourself to configure it as a ...


3

You can use one of the PWM pins on Arduino to output a PWM signal. If you want a constant clock, you need to set the duty cycle of the PWM to be 0.5, i.e. 50%. Syntax: analogWrite(pin, value) where the parameter "value" is the duty cycle ranges from 0 (always off) to 255 (always on) since it is a 8-bit PWM generator inside Arduino. If you need a PWM wave ...


3

I've built a few 3.3v home-brew-duinos with 16Mhz crystals (because I have a bag of 50 xtals!) - they run fine in the conditions I've put them in so far (on my desk). Some of them may be closer to their margins than others, and might fail at at some otherwise in-spec temperature, for example. If these were intended to go outside (enclosed, of course), I'd ...


3

If you reduce the main clock speed by 50% then everything else is reduced by 50% as well. The whole chip runs at half the speed. That includes things like the UART. For example, the bootloader is set to run at 115200 baud on a 16MHz chip. If you run that same chip, with the same bootloader, at 8MHz then the bootloader will actually be running at half the ...


3

As I said in my comment, the idea of using the Arduino's own PWM as a clock source is completely misguided. It will be no more accurate than using millis() or micros(): both these functions and the PWM rely on the same primary clock source, namely the ceramic resonator clocking the chip. Also, you should avoid using delay() for timekeeping. The time it ...


3

It depends on how you're programming it. If you're using a bootloader to accept programming commands via a serial connection then you will need to use the clock method specified by the fuses currently programmed, since the chip at that point will actually be running code programmed on it. If you're using ISP to program the chip out-of-band then you can ...


Only top voted, non community-wiki answers of a minimum length are eligible