Atmega128 breakout board

Go To Last Post
21 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello people,

This is my first time posting here.

 

I have designed a breakout board for atmega128, when I tried to program it using USBasp, I got this error every time:

>avrdude -c usbasp -p m128 -b 19200 -v

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbasp
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega128
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom         4    12    64    0 no       4096    8      0  9000  9000 0xff 0xff
           flash         33     6   128    0 yes    131072  256    512  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          4    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: error: program enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude done.  Thank you.

 

and I got this error when I utilized Arduino nano as Avrisp:

>avrdude -c avrisp -P COM3 -b 19200 -p m128 -v

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : avrisp
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega128
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom         4    12    64    0 no       4096    8      0  9000  9000 0xff 0xff
           flash         33     6   128    0 yes    131072  256    512  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          4    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel AVR ISP
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.07s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.06s

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

avrdude done.  Thank you.

 

I have tried all the stuff stated below:

  1. Updating USBasp firmware.
  2. A jumper on J3.
  3. -B with several values.
  4. Setting the baud rate to 19200.
  5. Using 2 Arduino Nanos to make sure it is not a programmer issue.
  6. Soldering 3 different boards to make sure it is not a soldering issue.
    • I used atmega128 chip ordered from LCSC once, and 2 chips ordered from Aliexpress on the 2 boards left.
  7. Tried using the Mega Core library. Same problems.
  8. Pulling up the RESET pin.
  9. 0.1 µf capacitor between GND and VCC
  10. Programming Atmega328 using the same procedure, and it was done successfully.

 

I have checked the schematic several times, but still unable to detect something wrong. You may be able to detect one:

 

I think it is quite obvious that I am using the same approach as the one used to program Atmega328, am I doing the right thing?

I have been working for one week now with no luck, your help is much appreciated.

Thanks in advance.

This topic has a solution.
Last Edited: Thu. Jul 23, 2020 - 03:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

To program via ISP, the ISP clock must be no faster than FCPU/4. where FCPU is the actual CPU clock frequency at the time that programming is attempted.

 

NB: when you attempt to change a clock frequency via fuse, that change does not become effective until the NEXT reset.

 

Also note that this is NOT the same as the baud rate.

 

Even further, this means that the M128 HAS to have a running clock. Thus, if it has been previously fused for an external clock or crystal, those MUST be connected. Default is internal 1MHz oscillator. That means that the ISP clock must be NO FASTER than 250KHz; 125KHz is a good place to start.

 

A common error is to program a device with an external crystal for "external oscillator". Once you have done that, it will not program. Your choices in this case are (1) start over with a new chip or (2) supply an external clock signal to XTAL1 pin.

 

Jim

 

 

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

Last Edited: Mon. Jul 20, 2020 - 06:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Your capacitor on aref is wrong.

You should have 3 100nf capacitors on vcc, one for each pin and they should be adjacent to the chip.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Mega128 uses PE0, PE1 pins for ISP.

 

It looks as if you have made a 10-pin header U1 that "matches" USBASP but does not use the correct ISP port pins.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome to AVRFreaks!

 

Schematics consisting of only netlists are discouraged here, we are not computers, so you would be well advised to actually "Draw" a schematic showing all connections via lines!!!

 

Given that, I did not see power on the AVCC pin, with out this your chip will not run, like wise every power pin pair VCC/GND and AVCC/GND pin pair must have a 100nf cap as close to the pins as possible.

Until you can read the signature of the chip, nothing will work, so check your connections and make corrections.

Make sure you reset the M103 fuse, as it is set by default on this chip, once you can read the signature.

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

On top of the above, the resistor on the Reset line should be 10K or higher.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1


david.prentice wrote:

Mega128 uses PE0, PE1 pins for ISP.

 

It looks as if you have made a 10-pin header U1 that "matches" USBASP but does not use the correct ISP port pins.

 

Indeed. From the datasheet:

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

js wrote:
On top of the above, the resistor on the Reset line should be 10K or higher.

 

I seem to remember reading in a mega datasheet somewhere that the internal pull-up resistors on the ports are something like 20-30k and the RESET pull-up was 50-60k.  Of course, now I can't find it.  Being lazy, I set all ports to input with pull-up enabled during init, and just use a button to ground for reset.  No pull-up thinking I have 60k already.  Infinite is greater than 10k.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have always been using 4K7 because that's what I used to use with the 68HC11 chips but 10K has been the recommended value.

 

Of course it also depends on the environment the chip is working in, for low or no noise environment you can get away without a pull up resistor or cap, it's another story in an automotive environment for instance.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

js wrote:
Of course it also depends on the environment the chip is working in, for low or no noise environment you can get away without a pull up resistor or cap, it's another story in an automotive environment for instance.

 

Yeah, the only noise I have is the 125kHz continuously coming off the big RFID coil on the wall behind my bench.  Otherwise I am pretty low noise.  The cap is a problem with debugWire on the mega328P I think, so I have gotten used to leaving it off too.  Plus the diode recommended by Atmel so the cap doesn't discharge violently into Vcc.  Plus, I am discovering I must be lazy.  Not a good realization.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

js wrote:
I have always been using 4K7 because that's what I used to use with the 68HC11 chips but 10K has been the recommended value.

I also seem to remember the pull-up resistor on the RESET pin on the mega328P has to be larger than 10k to use debugWire with the Atmel ICE, but I cant find where I saw that either.  I am operating totally on my memory here, which I have come to distrust.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A cap from AREF to VCC?

no decoupling caps.

Reset should have a HIgher impedance resistor eg 10K and a small cap to ground I normally take 10nF  or 1nF whatever I have already in use.

and when you get to the point were you can change the fuses do not forget the M103 fuse.

A 5V LDO with 5V input voltage... that is not going to do much, just bridge it.

 

edit:

 

O and have a look at the Mega1281 data sheet. with a simple change you can also use that as it is almost pin compatible, will give you much more joy in the future.

Last Edited: Tue. Jul 21, 2020 - 05:40 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

js wrote:
I have always been using 4K7 because that's what I used to use with the 68HC11 chips but 10K has been the recommended value.

MarkThomas wrote:
I also seem to remember the pull-up resistor on the RESET pin on the mega328P has to be larger than 10k to use debugWire

AN2519 wrote:
The recommended pull-up resistor value is 4.7 k or larger when using STK600 for programming. For DebugWIRE to function properly, the pull-up must not be less than 10 k.

 

 

meslomp wrote:
Reset should have ... a small cap to ground

Not if you want to use debugWIRE or PDI:

AN2519 wrote:
To protect the Reset line from further noise, connect a capacitor from the RESET pin to ground. This is not directly required since AVR devices internally have a low-pass filter to eliminate spikes and noise that could cause reset. Using an extra capacitor is an additional protection. However, such extra capacitor cannot be used when DebugWIRE or PDI is used.

 

http://ww1.microchip.com/downloads/en/Appnotes/AN2519-AVR-Microcontroller-Hardware-Design-Considerations-00002519B.pdf

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Tue. Jul 21, 2020 - 07:13 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

So, pulling all those errors together...

 

1) AREF should be connected to GND via a 100nF capacitor, not as shown

2) The resistor on /RESET should be 10k

3) You should have 3 100nF capacitors on the VCC rail, one physically adjacent to each (A)VCC/GND pin pair

4) You show power to the board from a USB connector. That will be 5V but you then feed that to a 5V regulator. That won't work, the regulator needs at least 6.3V input to work

5) You have the ISP pins connected to the wrong port

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So I did remember correctly.  I remember getting a handful of Nano clones from China that had 1k pull-up resistors.   I replaced one with a 10k, and there was a cap from the RESET pin to the CH340 USB chip, I think the DTR pin, or something like that, that I had to break the trace to.  I don't use the Arduino IDE or USB for programming the flash, so I didn't need that reset after programming functionality.  They have a 6 pin ISP header on them, a reset button, and USB for UART.  Seemed like a good deal for $2, and probably smaller than I could make myself with DIP chips.  I still have a bunch of them I will probably never use.  I think about 10% of them had some problem with USB, and they would smoke if you put external power to the Vin pin with USB plugged in.  You had to plug USB in after external power.  I think the voltage regulators fried if they already had 5V from USB when external power was applied.  I blew up a few before I figured out what was going on, but they were so cheap I didn't care about the flaky USB or burning up a few.  Just toss them in the recycle box and get a new one.

 

Edit:  I'm going off track talking about mega328.  Sorry.  This is a mega128 thread.

Last Edited: Tue. Jul 21, 2020 - 07:52 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A cap from AREF to VCC?

Certainly the expected layout is for the ARef cap to be connected to Ground.

 

For this purpose, however, as the voltage source itself has a very low impedance, I really don't think it matters much.

 

That "error" certainly isn't the reason the board can't be programmed, (which is due to the other issues mentioned above).

 

JC 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You are amazing guys,

When I connected MOSI MISO pins to E0 E1, it worked like a charm.

I will update the design for sure, and thanks for your suggestions.

 

Actually I am a newbie and I have mistakenly ordered atmega128 instead of atmega328 but I decided to challenge myself and get it to work. Indeed, I've learned something new today.

 

Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Interesting chat about debugWire in this thread. All we need now is for mega128 to actually get debugWire and we'll be sorted! (remember it's an old school JTAG/ISP chip!)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have checked the schematic several times

Um check what? Barely anything is drawn...you might as well just put a bunch of pin names and numbers in an Excel spreadsheet & do a column sort...that is NOT called a schematic, that is called a netlist.

The full drawing allows your brain to visually see what is connected to what.  With this powerful portable visualization tool, it can rapidly spot faults that would otherwise go unseen in a sea of numbers and labels.   

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

Interesting chat about debugWire in this thread. All we need now is for mega128 to actually get debugWire and we'll be sorted! (remember it's an old school JTAG/ISP chip!)

 

That's my fault Cliff.  I derailed it from the talk about pull up resistor and capacitor values on RESET.  Again, my apologies.  It is a bad habit I seem to have.