I want to use a seperate ATmega328P for to replace some older interface chips (SD <-> 8-bit parallel, and PS/2 -> 8-bit parallel) so i tested if i could program it without having to have the Arduino boot loader on it
i used the Arduino IDE to write a small program that just blinks an LED (1sec on, 1sec off), exported the file as Binary and loaded that onto the chip with the TL866II Plus
Caps: 22 pF
Resistor: 1 kOhm
Crystal: 20 MHz (like it says on the site)
and once i powered it it worked... sort of
now here is the problem, the LED is on and off for around 15 seconds instead of the programmed 1 second.
did i do something wrong with the circuit? or the program? when using the binary files i used the one without bootloader, is that the problem or why is the chip so much more slower than it should be.
You can't do much wrong with that program. It is so simple.
I guess you should look at the fuse settings on the chip. It looks like the standard is an effective 1 MHz clock rate and your program is expecting 16 (or maybe 20) times that.
6v6gt:
You can't do much wrong with that program. It is so simple.
I guess you should look at the fuse settings on the chip. It looks like the standard is an effective 1 MHz clock rate and your program is expecting 16 (or maybe 20) times that.
isn't the chip set to run at 20MHz like it says on Digikey? do i have to change the Arduino IDE to 20MHz somehow?
No, the digikey number is the MAXIMUM ALLOWED clock rate.
You have to set the CHIP (using the fuses) to know that it has an external crystal that it should use, and not to do additional modifications of the clock. (The default is to run from an 8MHz internal clock, and to further divide that by 8, giving a 1MHz final clock rate.)
I think you want to un-set all the checkboxes in the first column (Fuse Low Byte) EXCEPT for CKSEL3.
See the chip data sheet, and/or http://www.engbedded.com/fusecalc/
The process of loading the Arduino bootloader onto the chip via the Arduino IDE sets the fuses on a raw chip. You have chosen not to use the bootloader but if you compiled the program in the Arduino IDE, what target board did you select? A standard Uno for example would generate code assuming a 16Mhz crystal.
6v6gt:
The process of loading the Arduino bootloader onto the chip via the Arduino IDE sets the fuses on a raw chip. You have chosen not to use the bootloader but if you compiled the program in the Arduino IDE, what target board did you select? A standard Uno for example would generate code assuming a 16Mhz crystal.
I selected the Uno.
Wish I knew how to set it to expect a 20 MHz clock
westfw:
No, the digikey number is the MAXIMUM ALLOWED clock rate.
You have to set the CHIP (using the fuses) to know that it has an external crystal that it should use, and not to do additional modifications of the clock. (The default is to run from an 8MHz internal clock, and to further divide that by 8, giving a 1MHz final clock rate.)
I think you want to un-set all the checkboxes in the first column (Fuse Low Byte) EXCEPT for CKSEL3.
See the chip data sheet, and/or AVR® Fuse Calculator – The Engbedded Blog
Alright I need to set those checkboxes right and try again.
Also does this mean 20 MHz is too much? Now I already brought like 4 20 MHz crystals for this.
It looks like you are missing the 0.1 uF decoupling capacitors on the power lines. You might get by without them but really you should use them
well it was just to test the circuit. so i didn't thought it would be nessesary since it's only temporary
6v6gt:
Good work. And you are sure it is blinking at 1.0 second intervals and not 0.8 (16/20) second intervals.
after testing again, it is actually a bit slower than a second. i held it up next to my windows clock and after a few seconds it falls behind the clock.