NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » Is it possible to scale the crystal clock down to 8 MHz?
May 14, 2011 by rboggs10 |
I want to scale it down to 8 MHz. |
---|---|
May 14, 2011 by esoderberg |
RBoggs, Yes. See page 27 of datasheet. The chip has an 8MHz internal oscillator that can be used in lieu of an external source. Eric |
May 14, 2011 by rboggs10 |
Thanks Eric. |
May 14, 2011 by rboggs10 |
But how do I use this internal Oscillator? |
May 14, 2011 by Noter |
To use the internal oscillator you have to change the fuse settings on the chip. Changing fuse settings can not be done via the bootloader and another type of programmer is required. The most popular is the usbasp type that can be purchased in kit form. Ricks library article on installing the bootloader is a good place to find more info on using the usbasp and setting fuses. Just curious, why do you want to use the 8MHz clock? |
May 15, 2011 by rboggs10 |
I want it to be 8 MHz because I am doing a test with PWM to try and play musical notes through it. If I have an 8 MHz clock then by my calculations each PWM count should be an even 1us instead of the 0.5425us with the 14.7456 MHz clock. This even clock count would make it much easier for me to play exact musical notes.
|
May 15, 2011 by Noter |
Could you use a function to set the OCR1A value? Something like
Then you would use the function to set OCR1A to the correct value - setOCR1A(20.0); Or make a function where you can give a frequency. It may not be as perfect as using the 8MHz clock but maybe your ear won't know the difference. I think crystals are accurate to 100ppm and the max error in calculation would be another 100ppm. |
May 16, 2011 by rboggs10 |
That sounds pretty good I will give it a try and if it doesn't work out the way I want it then I have an 8 MHz Crystal on it's way. |
May 16, 2011 by Rick_S |
Just so you know, (in case you don't already), if you change the crystal you will no longer be able to load a program with the bootloader and NK hardware without replacing it with the original crystal. Rick |
May 16, 2011 by bretm |
Is 8MHz actually better for music than 14.7456MHz? For equal-tempered scale you have:
I'm not clear why one is better than the other. The relative error if you round to the nearest clock cycle count is actually smaller, on average, for the faster clock. |
April 16, 2012 by RogerFL |
For applications that don't require the speed or time accuracy, it would be nice to eliminate 3 parts on a PCB (crystal and its two caps) but still have a working serial programming solution. Any idea on what it would take to get the bootloader to support the internal oscillator? Ideally, the oscillator speed is a macro so we change it to 8000000. Change the fuse setting. Recompile and reload. Would we also need to slow down the serial connection? Anyone tried it? |
April 16, 2012 by Ralphxyz |
Of course you could allways use a programmer and load the .hex directly without a bootloader. If the mcu will be dedicated to this app it does not need a boot loader plus you get more programming space. Search the forum for ISP Programmer. Ralph |
May 08, 2012 by RogerFL |
Started working on this again. Got the bootloader to support 8MHz internal for 2 out of 3 steps for loading. It reads, writes, but always fails when reading flash in final step (I guess to verify). Fails with error msg: butterfly_recv(): programmer is not responding |
Please log in to post a reply.
Did you know that you can adjust most wire strippers to make it easier to strip insulation faster? Learn more...
|