Author Topic: Atmega328p on a breadboard, crystal hz problem.  (Read 1317 times)

0 Members and 1 Guest are viewing this topic.

Offline LittleRainTopic starter

  • Contributor
  • Posts: 47
  • Country: ca
Atmega328p on a breadboard, crystal hz problem.
« on: September 11, 2018, 04:29:35 am »
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?




 

Online ttelectronic

  • Regular Contributor
  • *
  • Posts: 56
  • Country: ca
Re: Atmega328p on a breadboard, crystal hz problem.
« Reply #1 on: September 11, 2018, 04:34:04 am »
Are the fuse bits set correctly?
 

Offline t1d

  • Super Contributor
  • ***
  • Posts: 1248
  • Country: us
Re: Atmega328p on a breadboard, crystal hz problem.
« Reply #2 on: September 11, 2018, 04:38:14 am »
Are the fuse bits set correctly?
Ditto...

And, can't breadboards cause unwanted capacitance? If so, could that be effecting the oscillator?
 

Offline LittleRainTopic starter

  • Contributor
  • Posts: 47
  • Country: ca
Re: Atmega328p on a breadboard, crystal hz problem.
« Reply #3 on: September 11, 2018, 04:45:52 am »
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.
 

Online ttelectronic

  • Regular Contributor
  • *
  • Posts: 56
  • Country: ca
Re: Atmega328p on a breadboard, crystal hz problem.
« Reply #4 on: September 11, 2018, 04:50:41 am »
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.
 

Offline LittleRainTopic starter

  • Contributor
  • Posts: 47
  • Country: ca
Re: Atmega328p on a breadboard, crystal hz problem.
« Reply #5 on: September 11, 2018, 04:57:19 am »
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.
« Last Edit: September 11, 2018, 05:46:30 am by LittleRain »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf