Author Topic: ATmega8 with arduino as ISP programming issues...  (Read 72506 times)

0 Members and 1 Guest are viewing this topic.

Offline GabYoung92Topic starter

  • Regular Contributor
  • *
  • Posts: 138
  • Country: au
ATmega8 with arduino as ISP programming issues...
« on: July 17, 2012, 06:35:16 am »
I have searched around for answers but I haven't been able to get my problem solved :(

After building myself a linear PSU, I wanted a voltage panel.  I did not like any pre-made ones so I decided to make one myself using 4x 7-segs and a microcontroller using the chips' ADC.

I bought an ATmega8 chip and did some basic programming with it using my freetronics Eleven (UNO) to program it as an ISP.  (I did not burn a bootloader as I don't need it).  Using the Arduino IDE (1.0.1) I was able to program the blink program onto the ATmega8 chip using my Eleven as the ISP. I modified the program and re-uploaded to the chip a couple of times with no problems.  Throughout testing of the chip, I did not have an external oscillator connected and it still worked.

Now a week later, after writing my program.. I can not seem to get it to upload!  I have checked my wiring over and over, pinouts, and voltages... No luck! :(

But when I select the "Arduino NG or older w/ Atmega8" (which I used when i first got the chip) I keep getting the error
- "Yikes! Invalid device signature.Double check connections and try again, or use -F to overridethis check.".

I have followed http://arduino.cc/forum/index.php?topic=112452.0 and I get an error of: avrdude:
- "stk500_getsync(): not in sync: resp=0x66"

I'm lost because I know I had it working.. 

Any ideas of what I could do to fix this?
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10224
  • Country: nz
Re: ATmega8 with arduino as ISP programming issues...
« Reply #1 on: July 17, 2012, 06:49:04 am »
If you have another ATMEGA8 lying around, just try swap them around. It's so easy to do you might as well try it first.
It proves the chip and fuse bits aren't the issue.

You don't seem to have any resistors on those LEDs?
If their being driven directly from an I/O port, and haven't exploded, it will be because they're pulling the I/O voltage down by a few volts.
This maybe preventing the programming signals from being detected.
(Note if the programmer board has its own resistors then you can ignore this comment)

Double check the
- Power and Ground connections
- RESET, SCK, MISO, MOSI and remember M=master S=slave I=input O=output
- Remove that pullup resistor you have between RESET and VCC (It doesn't need it and if it's pulling too hard it maybe causing issues)

When checking connections connect the DMM probe between the actual pin of the IC and the header of your programmer. This checks all connection points along the way.
Also check all pins for a short to their adjacent pins.

Put your program aside and try a brand new program. Just something simple that blinks a led.

If it still doesn't work then pull all the wires and chips out of the breadboard. Rotate the breadboard 180 degrees and rebuild your circuit.
Often you get bad connections with breadboards.

Sometimes with small circuits it's quicker to just rebuild than to try and track down the problem.
« Last Edit: July 17, 2012, 07:01:12 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline GabYoung92Topic starter

  • Regular Contributor
  • *
  • Posts: 138
  • Country: au
Re: ATmega8 with arduino as ISP programming issues...
« Reply #2 on: July 17, 2012, 09:05:40 am »
I've only got the one chip :( (Other than an ATmega8515 that I couldn't program?)

Nope I didn't have resistors connected. This is how I did it the first time. 

I've now used a resistor for the status LED's (driven from the programmer) and I've removed the pullup resistor as well. I tried to upload again and got:

- avrdude: Expected signature for ATMEGA8 is 1E 93 07
         Double check chip, or use -F to override this check.

Re-uploading gives me :

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

The chip is an ATmega8  (picture attached)

I deleted my Arduino IDE, re-downloaded the latest and tried, no luck :( 
I'm thinking that I may have to connect an external oscillator.
 

Offline GabYoung92Topic starter

  • Regular Contributor
  • *
  • Posts: 138
  • Country: au
Re: ATmega8 with arduino as ISP programming issues...
« Reply #3 on: July 17, 2012, 09:09:24 am »
I've checked all the connections for continuity.  No issues there.  I checked the pins on each ATmega.  And there are no shorts.

And I've tried putting the chip on a different breadboard, still the same issues.


I've got a feeling that I'm experiencing what's written in this thread:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=99652
« Last Edit: July 17, 2012, 09:14:31 am by GabYoung92 »
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10224
  • Country: nz
Re: ATmega8 with arduino as ISP programming issues...
« Reply #4 on: July 17, 2012, 09:14:54 am »
Sometimes fuse bits do get corrupted, but normally it happens while your working not between putting the project aside and picking it up again later.

If it was me, i'd try and reprogram it with a simple printer port connection. That would rule out the programer board.

An external oscillator is worth a try
« Last Edit: July 17, 2012, 09:23:38 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline GabYoung92Topic starter

  • Regular Contributor
  • *
  • Posts: 138
  • Country: au
Re: ATmega8 with arduino as ISP programming issues...
« Reply #5 on: July 17, 2012, 09:19:30 am »
Damn,  I had ordered some but still waiting for them to arrive.  Would it be possible to link off of the oscillator on the Arduino board connected to the Atmega328p?
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10224
  • Country: nz
Re: ATmega8 with arduino as ISP programming issues...
« Reply #6 on: July 17, 2012, 09:28:13 am »
There is a website somewhere that shows someone resetting the fuse bits on a ATMega using some switches to simulate the high voltage programming mode.

ie, entering the programming mode and sending commands by hand with switches on all the i/o pin!

I cant find the url though, also not sure if it was an atmega8.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8405
Re: ATmega8 with arduino as ISP programming issues...
« Reply #7 on: July 17, 2012, 10:17:35 am »
There is a website somewhere that shows someone resetting the fuse bits on a ATMega using some switches to simulate the high voltage programming mode.

ie, entering the programming mode and sending commands by hand with switches on all the i/o pin!

I cant find the url though, also not sure if it was an atmega8.
This?

http://ilikebugs.blogspot.com/2006/09/avr-necromancer.html

A bit tedious, but it works if you follow the instructions in the datasheet. I've done it a few times.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10224
  • Country: nz
Re: ATmega8 with arduino as ISP programming issues...
« Reply #8 on: July 17, 2012, 12:38:20 pm »
yeah, i think that's the one.

I remember it having more detail though
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline Erwin Ried

  • Regular Contributor
  • *
  • Posts: 206
  • Country: no
Re: ATmega8 with arduino as ISP programming issues...
« Reply #9 on: July 17, 2012, 08:25:20 pm »
Usually the programmers set the lock bits to avoid reprograms :D I have lots of attinys dead because of that, you can build an HV programmer and it works but I am waiting now a attiny resetter to automate the process.

Check this: http://www.microcontrollerprog.com
My website: http://ried.cl
 

alm

  • Guest
Re: ATmega8 with arduino as ISP programming issues...
« Reply #10 on: July 17, 2012, 10:50:03 pm »
Why would you need a HV programmer to clear the lock bits? Erasing the chip should clear them.

If you screwed up the clock fuses (eg. external clock), you may need to provide a clock source. You can usually feed it a square wave, unless it was set to LF crystal, then you need a 32 kHz crystal. If you set the RSTDISBL fuse, then you do need a HV programmer to clear it.

Like Psi, I would also suspect bad wiring or poor breadboard contacts.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10224
  • Country: nz
Re: ATmega8 with arduino as ISP programming issues...
« Reply #11 on: July 18, 2012, 01:46:55 am »
The other thing you can get is shorts between breadboard sections when you put a long wire into the board.
The wire can sometimes bend over inside and start moving sideways until it hits another conductor.

It tends to happen on the cheap breadboards.

You do have the programmer MOSI connected to slave MISO and vice versa right?
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline GabYoung92Topic starter

  • Regular Contributor
  • *
  • Posts: 138
  • Country: au
Re: ATmega8 with arduino as ISP programming issues...
« Reply #12 on: July 18, 2012, 10:56:01 am »
Quote
The other thing you can get is shorts between breadboard sections when you put a long wire into the board.
I've made my own jumper leads using pin headers and heat shrink to cover the joint. So should be no issues there, hopefully. 


I bought another ATmega8, hooked everything up (programmer and the circuit), programmed the chip and away it went with no problems. Displays lit and did exactly what I wanted.  I modified my code a little and went to re-upload it (Didn't touch any wires) and now from the Arduino IDE, i'm getting:

avrdude: verification error, first mismatch at byte 0x02e9
         0xe9 != 0xe0
avrdude: verification error; content mismatch

My code is designed to light one segment, darken it, and light the next one.  Sweeping all the segments to have a constant display.  Now it is slowly scanning across (about 1 second to do a sweep)  ?

 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8405
Re: ATmega8 with arduino as ISP programming issues...
« Reply #13 on: July 18, 2012, 10:59:55 am »
Noisy environment during programming can cause that. Ensure the wires to the programmer are as short as possible and located away from any sources strong EM fields.

It's not behaving as you want because the code has been corrupted. Do a full chip erase, and try again.

Also keep in mind ESD precautions.
 

Offline GabYoung92Topic starter

  • Regular Contributor
  • *
  • Posts: 138
  • Country: au
Re: ATmega8 with arduino as ISP programming issues...
« Reply #14 on: July 18, 2012, 11:01:20 am »
Noisy environment during programming can cause that.

Do a full chip erase, and try again.

Sounds likely.  I am using decoupling caps.  Is the erase possible using the Arduino as the ISP?

Thanks
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1310
  • Country: 00
Re: ATmega8 with arduino as ISP programming issues...
« Reply #15 on: July 18, 2012, 11:06:33 am »
Noisy environment during programming can cause that. Ensure the wires to the programmer are as short as possible and located away from any sources strong EM fields.

It's not behaving as you want because the code has been corrupted. Do a full chip erase, and try again.

Also keep in mind ESD precautions.

Also, put some caps on your breadboard.  Put a small cap (~10uF) across the power rail and ground and put a 100nF across the MCU's power pins, VCC and GND.
 

Offline GabYoung92Topic starter

  • Regular Contributor
  • *
  • Posts: 138
  • Country: au
Re: ATmega8 with arduino as ISP programming issues...
« Reply #16 on: July 18, 2012, 11:18:09 am »
Also, put some caps on your breadboard.  Put a small cap (~10uF) across the power rail and ground and put a 100nF across the MCU's power pins, VCC and GND.

Yup, I'm using decoupling capacitors on my breadboard.  I'm using 10uF across the rails, and 10nF greencaps directly next to the chip.

I've tried to upload

Code: [Select]
void setup()
{}

void loop()
{}

and i'm still getting a mismatch error. 


Is the device now locked from any more programming?
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10224
  • Country: nz
Re: ATmega8 with arduino as ISP programming issues...
« Reply #17 on: July 18, 2012, 11:22:14 am »
avrdude: verification error, first mismatch at byte 0x02e9
         0xe9 != 0xe0
avrdude: verification error; content mismatch

This means the micro is responding OK and being programmed with your code, but when it read the code back out of the micro the two didn't match.
So there's a corruption happening somewhere.
This is almost always a bad connection, noise on the power/ground connection or overly long cables.


Sometimes i see micros that will run even with a power or ground wire disconnected as the power feeds in through one of the I/O ports from somewhere else.
In this situation you get all sorts of errors like that.
Maybe put an LED+resistor across the ATMega8 vcc/gnd pins to check there is voltage/current there. It should not dim when you try and program the chip.

Also be sure you have connected all VCC and all GND pins. As well as AVCC.
You shouldn't leave any power/ground pins unconnected.



When you get stuff like
Quote
Expected signature for ATMEGA8 is 1E 93 07
  -avrdude: Yikes!  Invalid device signature.
That means the MCU isn't responding at all.
It could be broken, unconnected or have its fuse bits set to ignore reprogramming

« Last Edit: July 18, 2012, 11:37:10 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline GabYoung92Topic starter

  • Regular Contributor
  • *
  • Posts: 138
  • Country: au
Re: ATmega8 with arduino as ISP programming issues...
« Reply #18 on: July 18, 2012, 11:39:41 am »
I have checked my voltages on the pins.  Any pin that needs 5V, I've measured around the range of 5.1volts. 

GND pin 8 connected to GND
GND pin 22 connected GND

VCC pin 7 connected to +5V
AVCC pin 20 connected to +5v

AREF pin 21 floating.

I've attached extra code to set digital pin 0 (pin2) to high.  I'm still only reading 0.1V on that pin.    I'll pull all the wires out and start again?
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1310
  • Country: 00
Re: ATmega8 with arduino as ISP programming issues...
« Reply #19 on: July 18, 2012, 11:50:20 am »
Have you tried running avrdude manually from the command line?  You might try running it to see if you can get into terminal mode. 

I'm guessing you'd type something like this:

avrdude -p m8 -c arduino -t

I don't know if you need the -P option or not.  You might mess around with the different command line option that affect timing to see if they help.  I suspect your MCU is running at 1 MHz but your programmer is trying to upload data at a faster rate.
 

Offline GabYoung92Topic starter

  • Regular Contributor
  • *
  • Posts: 138
  • Country: au
Re: ATmega8 with arduino as ISP programming issues...
« Reply #20 on: July 18, 2012, 12:20:16 pm »
Code: [Select]
avrdude -p m8 -c arduino -P COM7 -t

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f
avrdude: Expected signature for ATMEGA8 is 1E 93 07
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.

I posted a link earlier of a tutorial I followed.  I added to the board.txt file this: and I was using this to utilize the internal oscillator
Code: [Select]
atmega8u.name=ATmega8-noxtal @8MHz

atmega8u.upload.protocol=arduino
atmega8u.upload.maximum_size=7168
atmega8u.upload.speed=19200

atmega8u.bootloader.low_fuses=0xe4
atmega8u.bootloader.high_fuses=0xc2
atmega8u.bootloader.path=atmega8_noxtal
atmega8u.bootloader.file=ATmegaBOOT.hex
atmega8u.bootloader.unlock_bits=0x3F
atmega8u.bootloader.lock_bits=0x0F

atmega8u.build.mcu=atmega8
atmega8u.build.f_cpu=8000000L
atmega8u.build.core=arduino
atmega8u.build.variant=standard
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10224
  • Country: nz
Re: ATmega8 with arduino as ISP programming issues...
« Reply #21 on: July 18, 2012, 12:20:56 pm »
From reading that config file am i right in assuming you're trying to run the onboard RC osc at its max 8mhz?
Because i always had programming issues doing that myself. 1Mhz was fine but anything above 4mhz on the RC i found unstable for ISP programming.
The issue went away using a crystal instead.


Have you tried running avrdude manually from the command line?  You might try running it to see if you can get into terminal mode. 

I'm guessing you'd type something like this:

avrdude -p m8 -c arduino -t

I don't know if you need the -P option or not.  You might mess around with the different command line option that affect timing to see if they help.  I suspect your MCU is running at 1 MHz but your programmer is trying to upload data at a faster rate.

Yeah, slowing down the data rate is definitely something to try.
-i 20 adds some ISP delay but I dunno if that works for arduino programmers?
« Last Edit: July 18, 2012, 12:28:49 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1310
  • Country: 00
Re: ATmega8 with arduino as ISP programming issues...
« Reply #22 on: July 18, 2012, 12:28:43 pm »
That signature must be of the chip on the Arduino board.  At least it matches that of an ATmega328.  Maybe that's not the way you launch avrdude when you're using the Arduino board as the programmer.  It isn't something I've ever tried to do myself.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10224
  • Country: nz
Re: ATmega8 with arduino as ISP programming issues...
« Reply #23 on: July 18, 2012, 12:31:25 pm »
Yes, that command seems to be trying to reprogram your programmer, not your ATmega8
AVRDUDE was looking for an ATmega8 and found a 0x1e950f (ATmega328) so aborted the process.
« Last Edit: July 18, 2012, 12:34:25 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1310
  • Country: 00
Re: ATmega8 with arduino as ISP programming issues...
« Reply #24 on: July 18, 2012, 12:34:08 pm »
I have to wonder if your Arduino has lost it's 'programmer' firmware.  Have you tried re-uploading it?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf