Notifications
Clear all

ATmega328P query

33 Posts
5 Users
1 Likes
7,841 Views
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
Topic starter  

@codecage, @dronebot-workshop

I have decided to try the 5V setup first, and have some 16MHz oscillators on order, which I should get on Saturday. But I don't have any 22pF caps, could I use 20pF caps instead?

 


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1037
 
Posted by: @pugwash

I have decided to try the 5V setup first

Not sure what you mean by the 5V setup.  I thought the two options for programming the bootloader on an ATmega328P was to do it at 8MHz or 16MHz.   And then which ever way you installed the bootloader was how it would need to be used.

And I would guess 20pf caps would work.  In the info I went thru recently I even saw 18pf caps being used,

SteveG


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
Topic starter  

@codecage

When I talk about the 5V setup, I mean using the external 16MHz oscillator, and references to 3.3V setup are to the internal 8MHz oscillator.

Sorry for the confusion.

After some more armchair research, it seems to me that this Nick Gammon fellow is the guru of bootloaders and I think I will try his bootloader programming sketch today!


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1037
 

@pugwash

Wow the Nick Gammon site has enough stuff that that my head was spinning after looking through it!

There was way more information than I needed on scenarios I haven't come across yet, but nothing on programming the non-P version of the 328.

I'm not clear on why you need his "methods" for programming an ATmega328P in the 16MHz (5V) setting.  I found that to be very straight forward using just my Uno and a proto board with the 16MHz crystal, two 22pf cap caps and one 10K resistor.  And the required jumper wires as well.

All of this was done with the tools available with the Arduino IDE and no additional software was needed.

SteveG


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
Topic starter  

@codecage

SUCCESS!

The blink sketch running on an ATmega328 at 8MHz and 3.3V without an external oscillator.

It should be noted that running on 3.3V does not work unless both sides of the chip are connected to Vcc and Gnd.


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
Topic starter  

@codecage

Wow the Nick Gammon site has enough stuff that that my head was spinning after looking through it!

This is really not as complicated as it seems at first glance.

All you need to do is download the github as a zip file. move the Atmega_Board_Programmer to your sketch folder, hook up the ISCP pins (note that the RESET pin on the slave is connected to pin 10 on the master) upload the sketch to the master and "Bobs your uncle!" IT WORKS!


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1037
 

@pugwash

Hooray!

Now is that a ATmega328 without the trailing "P", or is it a ATmega328P that you just didn't type the "P" in your SUCCESS post?

And, aren't all the tools you need right there in the Arduino supplied code, such that you don't need the Nick Gammon code at all?

As always I'm having a hard time seeing the forest for the trees.  And I want to be sure to understand all the pieces so I can write up a document that makes all this a little easier to explain. 

SteveG


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
Topic starter  

@codecage

I am only using ATmega328P.

The sketch from Nick Gammon was last revised in 2012 and he makes no reference to the "P" chip. Therefore I would guess that his code would work with the non "P" versions.

Have now got the code for my remote sensor uploaded and the remote is working perfectly.


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1037
 

@pugwash

Well the current tools provided with the current Arduino IDE do not handle the non "P" version, so my advise is to stay away from them unless you just happen to come across some for a very good price, like for free, or even better if someone pays you to take them off their hands.  But either way, make sure you double, triple, quadruple check that the bootloader is installed unless you want to jump though hoops as we have for the past few days.

I did notice the cap on the proto board next to the 10K resistor on pin 1 of the 328.  That is only necessary when uploading a sketch correct?  Did you use a USB to FTDI dongle to upload the BLINK sketch or does the Nick Gammon software also upload sketches as well as bootloaders?

If you used the USB to FTDI solution you just removed it and its associated wiring with the exception of that cap before filming your SUCCESS story I'm assuming.

SteveG


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
Topic starter  

@codecage

Did you use a USB to FTDI dongle to upload the BLINK sketch?

Yes!

As you see in the photo below, the red wire from DTR the FTDI board is connected to the cap, which in turn is connected to pin 1 between the 10K pullup resistor and pin 1 of the ATmega chip.

IMG 4250

If you used the USB to FTDI solution you just removed it and its associated wiring with the exception of that cap before filming your SUCCESS story I'm assuming.

Also yes!


   
ReplyQuote
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1075
 

@pugwash

I suspect a 20pf capacitor would work fine, you might even have the extra 2pf of capacitance in the wiring on the breadboard!

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ReplyQuote
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1075
 
Posted by: @pugwash

Nick Gammon fellow is the guru of bootloaders

He's more like the guru of everything Arduino, I constantly use his stuff as a reference.  He and Lady Ada deserve a lot of the credit for making the Arduino as popular as it is today.

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
Topic starter  

@dronebot-workshop

Thanks for the response, but I am now past the caps and 16MHz oscillator solution. Using an Arduino Mega as master and Uno as a slave, I did exactly what you said we shouldn't do. Namely prising the chip out of the Uno! ? But by carefully lifting each end with the tip of a Swiss Army Knife, no chip pins were bent!

So now I have got 5-off 16MHz oscillators and a bootloader shield pending delivery that I no longer need. ? 

But the overall result is quite pleasing, instead of a Nano consuming 30mA at 5V, I have now powered my remote sensors with 0.6mA at 3.3V. A considerable power saving.


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1037
 

@pugwash

Wow, quite a bit of an improvement there in the power consumption department!

SteveG


   
ReplyQuote
Evile
(@evile)
Member
Joined: 4 years ago
Posts: 12
 

Awesome research guys, that's really helpful, especially the video.


   
ReplyQuote
Page 2 / 3