Atmega328p on a breadboard, crystal hz problem. - Page 1
Forum section: electronics / projects

author: LittleRain
author_rank: Contributor
timestamp: September 11, 2018, 04:29:35 am
content: Trying to create an "arduino" on a breadboard, and for some reason so matter which schematic I try it just is not working.When I try to upload the bootloader, or upload a sketch AVR dude kept giving me an error with the clock frequency.I thought it may be the 328, so I swapped it with the one on my UNO, and I was able to upload a bootloader, as well as a the blink sketch no problem.The led on pin 13 was blinking confirming the 328 was ok, so I put the chip back in the breadboard and... Nothing.VCC/AVCC/AREF are all getting 5v, reset is pulled high, both GND are grounded, and the crystal is hooked up to two 22pf caps.I scoped the crystal, it isn't putting out the correct frequency, but it seems to be trying to.CH1 is the crystal, and CH2 is one of the caps.Any ideas?

author: ttelectronic
author_rank: Regular Contributor
timestamp: September 11, 2018, 04:34:04 am
content: Are the fuse bits set correctly?

author: t1d
author_rank: Super Contributor
timestamp: September 11, 2018, 04:38:14 am
content: Quote from: ttelectronic on September 11, 2018, 04:34:04 amDitto...And, can't breadboards cause unwanted capacitance? If so, could that be effecting the oscillator?

author: LittleRain
author_rank: Contributor
timestamp: September 11, 2018, 04:45:52 am
content: Fuse bits?I was thinking that the breadboard may be causing unwanted noise, but there are a ton of people doing this on youtube, so you think it would be fine, right?Gunna try another crystal, be back in a sec.

author: ttelectronic
author_rank: Regular Contributor
timestamp: September 11, 2018, 04:50:41 am
content: Yes, the default fuse bits that the atmega 328 are shipped with are set to use the internal oscillator, which is slower, and won't make use of the external crystal you are using.http://www.engbedded.com/fusecalc/t1d, yeah breadboards themselves can give some capacitance. Often enough it will oscillate without the capacitors. I can't recall if I've had one that the capacitors hindered the oscillation.

author: LittleRain
author_rank: Contributor
timestamp: September 11, 2018, 04:57:19 am
content: Ahh ok. Yes the youtube video mentioned that if you want to run it at 8mhz you can use a different bootloader.But I uploaded the regular arduino uno bootloader, so would be set to use an external crystal.I swapped crystals, no difference. But I read that using passive probes will alter the frequency.I tried hooking the postitive to the crystal, and ground to the ground of the cap and it seems to be putting out 16mhz.I guess something else must be the issue...Thanks for the replies though!If you have any other suggestions I'm all ears.Edit: So after you said something about the fuse bits, I remembered the youtube video mentioning the bootloader.Well Last night when I was trying to program the 328 on the breadboard, I wasn't having luck with my programmer. So to test my programmer I reuploaded the bootloader, to the original 328 on my UNO.After I did that, for some reason I was not able to upload sketches anymore to USB. I only could do it with my programmer.So I decided to try and fix that first. I read that people had the sketch upload issue after uploading the uno bootloader, and that uploading the nano bl, fixed their issue.I uploaded the nano bootloader into the uno, which fixed my usb uploading issue.I did the same to the other 328, then put one on the breadboard. Quickly made sure all the connections were good, and boom, tetris for jeff.Long story short, upload nano bootloader to the Uno (who would have thought that), check for bad connections, and it works.If I had realized that scoping the crystal can make it go wonky, I probably wouldn't have spent so long on the crystal.