Notifications
Clear all

Bootloader onto ATMega328P-PU Chip and Then Loading Sketch

36 Posts
4 Users
2 Likes
6,104 Views
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

@stargatefan

Have either of you tried using an FTDI adapter to upload?  If not, how do you upload your sketches once the bootloader is on the ATMEGA328P-PU?

Yes, and I have encountered no problems!

Bill Shows:
FTDI Pin DTR/RTS as Being 1st From Left (Facing Topside of Chip) Going to ATMega328 Pin 1 (Reset) Thru a 100 nF (104) Capacitor
FTDI Pin RX as Being 2nd From Left (Facing Topside of Chip) Going to ATMega328 Pin 3 (TX)
FTDI Pin TX as Being 3rd From Left (Facing Topside of Chip) Going to ATMega328 Pin 2 (RX)
FTDI Pin VCC as Being 4th From Left (Facing Topside of Chip) Going to +5 V (Can use same 5 V out of regulator supplying ATMega328)
FTDI Pin GND as Being 6th From Left (Facing Topside of Chip) Going to GND (Can use same GND out of regulator supplying ATMega328)
Pin 5 is Unused

That sounds about right, just remember that the 5V pin on the FDTI board is supplying 5V from the USB interface.


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

@stargatefan

Not looking at my entire setup at the moment as I'm getting ready for a function this evening.  But as a test that could confirm if your boot loader was indeed loaded correctly, you could remove the ATMega328P from you UNO, assuming your model has the 28pin DIP chip and just program it from there.  And assuming you used the 16MHz crystal to load the bootloader (unless I'm totally wrong on that front!).  If you have the UNO model with the SMD variety of the 328 then you won't be able to do that.

I haven't tried loading from a FTDI 'friend' on my newly loaded bootloader chips yet.  I've only done two chips so far and was in the process of assembling a breadboard circuit with a ZIF socket last week when I had an interrupt that hasn't allowed me to get back to my bench.  Maybe over this weekend.

SteveG


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

@stargatefan

If I'm remembering right, and there I go again, the cap is connected to pin 1 and the resistor is as well.  With the other side of the resistor still attached to 5V.  In other words, both are required.  I plan on putting a header on my breadboard to plug the FTDI board into so I don't have to leave it pemanently in place.  It looks like Bill has done this as well on his newly designed motor controller board for DB1.

Good luck!

SteveG


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

@pugwash

Not even sure I remember that there was a yesterday, much less what was for lunch!  ?  

SteveG


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

@stargatefan

@pugwash

There also seems to be some confusion on whether pins 20 & 22 need to be connected to 5V and GND.

I don't think you can go wrong connecting both sides of the chip to 5V and GND.

I've read somewhere that if you aren't using the analog pins then 20 & 22 aren't necessary, and I did notice the diagram that Jonathan was originally using only showed one of the two connected.  I used both on my circuit just to be on the safe side.

SteveG


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

@stargatefan

@codecage

I had problems uploading a sketch to a bare ATmega328 when only pins 7 & 8 were connected to Vcc and Gnd, albeit in 8MHz mode. No problems encountered with pins 20 & 22 also connected.

As I am using A4 & A5 for I2C, 20 & 22 must be connected for I2C to function. All the rest of the power saving is done with the Lowpower.h library.


   
ReplyQuote
(@stargatefan)
Member
Joined: 4 years ago
Posts: 15
Topic starter  

@Pugwash
@codecage

I've been slowly going down the list of boards.  Some of the boards said something about not finding the serial port I specified.  I remembered reading yesterday that the latest version of the driver from FTDI does not work with knockoff FTDI adapters.  I bought a 2 to $3 adapter off of AliExpress.  So I'm pretty sure it's a knockoff.  I just rolled back my driver to 2.08.24 from the FTDI website (something that poster yesterday said worked for them).  I've got the circuit wired up per Bill's schematic.  If this doesn't work I'm going to pull the chip out of the Arduino Uno board and used that to program the ATMEGA328P-PU.

Huh...still getting this message even with the older driver:
the selected serial port
does not exist or your board is not connected

In any case I'm running out of time to work on this today.  I'll have to see if I can get some time tomorrow.  I'll let you guys know how it works out.  Thank you so much for your help so far.


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

@stargatefan

Can you read the info on the IC surface?

One sure sign that something is wrong is where this info has been obliterated!


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

@pugwash

Well A4 and A5 are designated analog by the "A" so I guess that answers that question.  But if the FTDI board uses the digital TX and RX pins then maybe 20 & 22 might not be needed.

Are we learning or what?

SteveG


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

@codecage

I think the question of connecting or not connecting pins 20 & 22 during sketch upload is a bit academic. It certainly does no harm to have them connected as this is not the long term configuration.

I made up a breadboard for uploading the sketches with 20 & 22 connected because as I mentioned the ATmega328 would not accept the uploads without them connected, in 8MHz mode.

I guess if you are not using pins A0 to A5 in operational mode then you could disconnect 20 & 22 and try it out. And shout out to the world if your circuit works or not!

Think about Micheal Faraday, he didn't have a clue what he was doing or what he had discovered and was considered a bit of a clown by The Royal Society because he could not explain what he had found. Only when James Clerk Maxwell took all of his lab notes and wrapped Faraday's findings in mathematical formulas did Faraday finally get credit for discovering electro-magnetism.

MORAL - Keep experimenting!!


   
ReplyQuote
(@stargatefan)
Member
Joined: 4 years ago
Posts: 15
Topic starter  

@codecage
@Pugwash

If you mean on the IC surface for the FTDI adapter it says:

FTDI
1845-C
CN480661
FT232RL
I purchased it from this site:
https://www.aliexpress.com/item/32634246159.html?spm=a2g0o.detail.1000060.1.a87230d4wDX0M2&gps-id=pcDetailBottomMoreThisSeller&scm=1007.13339.146401.0&scm_id=1007.13339.146401.0&scm-url=1007.13339.146401.0&pvid=f5b58add-8f25-49b8-9648-decc5b761fbf

If you meant the ATMEGA328P-PU it reads
Atmel 35473D
ATMEGA328P U
1922S52

I haven't gotten a chance to continue with the testing of the different board options in the Arduino IDE.  I will try to find some time tomorrow since it is quite late now.

This is where I got the driver for the FTDI adapter
https://www.ftdichip.com/Drivers/D2XX.htm
I'm trying version 2.08.24.


   
ReplyQuote
(@stargatefan)
Member
Joined: 4 years ago
Posts: 15
Topic starter  

@codecage
@Pugwash

Alright.  Here is the verdict.  I spent several hours and was able to figure out how to load the star wars song sketch onto both chips I bootloaded with your help yesterday.  But in order to do it I had two put the ATMega328P-PU's I bootloaded into an Arduino Uno board.  These settings did it for me:

image

I tried using that cheapy FTDI adapter I bought off AliExpress.  I also tried wiring up the Arduino board without the ATMega it came with inside per the Arduino website:

image

But none of those options worked.  If I don't want to keep having to plug the chips into my Arduino board directly I see I have two options.

1) Find someone who has a working FTDI and find out exactly which one they bought
2) Figure out why the Arduino board can't load the sketch directly into the chip remotely.
It's weird.  The RX LED on the Arduino board will light up a couple of times.  But when a successful sketch goes through both RX and TX light up like crazy.  I even tried using the reset a couple of times.

Another option I am considering is this.  Bill said in his video that the socket built into the Arduino board wasn't meant to have chips repeatedly plugged in and out of it.  But I'm wondering if I can take one of the extra sockets I have and plug it into the socket soldered into the Arduino Uno board.  Then when female end of that socket eventually wears out I can just replace the extra socket easily.  I'll have to see if the socket fits when I get to work next week.

Do you guys have any thoughts?


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

@stargatefan

I am surprised at your choice of board. The Arduino Uno board worked for me!

The Duemilanove was designed in 2009 and uses the ATmega328 microcontroller and not the ATmega328P (low power microcontroller). The low power version was not available in 2009.


   
ReplyQuote
(@stargatefan)
Member
Joined: 4 years ago
Posts: 15
Topic starter  

@Pugwash

I did not know that.  I am relatively new to electronics.  So that isn't surprising. I can't recall if I tried the Arduino Uno (I may have).  The reason I selected it was because the instructions on the Arduino website (shown in the second picture of my previous post) told me to.  I learn new things each time I talk to you guys.


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

@stargatefan

My guess is that the bootloaders for the ATmega328 and 328P are different.

As for wearing out the slots on the Uno, you could probably change the microcontroller 50 times with no negative effect, I think this was Bill being a bit over-cautious. Of course, special care must be taken when installing and removing the microcontrollers on the Arduino.

If you are really going to program thousands of ATmega328's then one of these would be the better option.

s l225

28 pin ZIF sockets


   
ReplyQuote
Page 2 / 3