Switched atmega32A to 8Mhz internal osc, it works but cannot program it anymore

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

Hi,

 

I had a code (in Atmel Studio) in which I took average of ADC readings and displayed them on 9 LED digits. To make the micro controller faster, I changed the fuse bits to internal 8mhz internal oscillator and it seems to be working because I can see the LEDs update much faster (the sampling and averaging took well over a second @ 1Mhz), but I can't seem to program the microcontroller anymore. I get the error

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: programm 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.

 

The external tool I'm using in Atmel Studio is

avrdude -c usbasp -p atmega32 -U flash:w:$(ProjectDir)Debug\$(TargetName).hex:i -U lfuse:w:0xe4:m -U hfuse:w:0xd9:m

 

The fuse bits I changed to are low - E4, high - D9 taken from https://www.engbedded.com/fuseca... (I have JTAG disabled because I need to use PORTC). I'm using USBASP for programming.

 

Things I've tried:

1) Using -B parameter from 1 to 10.

2) Reading the unbrick AVR tutorial (I'm pretty sure that tutorial was not for my case but I didn't have much to lose). I supplied a high frequency wave from Arduino to XTAL1. I don't know the frequency of that wave but I basically used my Arduino Uno to turn on and off a digital pin.

int unbrick_pin = 3;
void setup() {
  // put your setup code here, to run once:
  pinMode(unbrick_pin, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(unbrick_pin, HIGH);
  digitalWrite(unbrick_pin, LOW);
}

and then connected it to XTAL1.

3) Using the -b baud rate parameter at various serial frequencies.

4) Using my Arduino Uno as ISP instead of usbasp.

 

It's really weird because the microcontroller is working perfectly but I just can't use avrdude to reprogram it.

Some more details :

1) Using windows 10, WinAVR

2) I get the following error when I use -v

 

avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"

         Using Port                    : lpt1
         Using Programmer              : usbasp
         AVR Part                      : ATMEGA32
         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    10    64    0 no       1024    4      0  9000  9000 0xff 0xff
           flash         33     6    64    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           calibration    0     0     0    0 no          4    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: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: programm 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.

I just realized that I might be using outdated version of AVR as I paste this verbose output, since it says 2010. I'll try to update and see but I doubt that's the case.

I get the following error when I use -F

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATMEGA32 is 1E 95 02

avrdude done.  Thank you.

 

This topic has a solution.
Last Edited: Wed. Nov 25, 2020 - 07:17 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your command looks fine to me.

 

If the current program is running then the AVR has obviously got a clock signal.

If it is running at 8MHz the fuse is obviously set for Internal 8MHz RC

 

I would expect avrdude and USBASP to read the Signature.    You have even got the (superior) Chinese firmware that will set the SCK speed automagically.

 

So it comes down to your wiring.

 

I suggest that you always use a proper 3x2 ICSP header with any programmer.    (or 5x2 header to match the USBASP ribbon cable)

Then you can plug in the ribbon cable and be confident about reliable wiring.    (identify pin #1 with a spot of paint or use box headers)

 

Yes,   ribbons do wear out after a lot of use.    But they are much better than random wires stuffed into random holes.

 

David.

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

Thanks for replying. I feel very embarrassed right now. You were correct...(a wiring mistake as my first post haha). One of my wires was not as reliable as I thought it was. I will do as you suggest in my future projects. In hindsight, I should have double checked the wires first, even though the problem occurred right after I changed fuses (made me think fuses were the issue).

 

EDIT: How do I mark this as solved?

Last Edited: Tue. Nov 24, 2020 - 12:25 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Even if you like breadboards,  it is worth making or buying an ICSP adapter.    An offcut of Protoboard with some male header strip.

Likewise you can make or buy a 3x2 to 5x2 adapter.

 

Pleased that you have things working.

 

Remember to assign the 8MHz Calibration value to OSCCAL in every program.

The 8MHz RC is fine for USART comms but only when OSCCAL=calibration_8MHz value

 

David.

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

david.prentice wrote:
it is worth making or buying an ICSP adapter. 
The Adafruit one is great. I recently got one of them in the UK from The Pi shop (which may seem a curious place to get AVR stuff - but they actually have a wide stock!). Highly recommend it for attaching a 6 pin ISP programmer to a breadboard.