Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 13th April 2008, 08:02 PM   (permalink)
Experienced Member
 
lord loh. is on a distinguished road
Send a message via Yahoo to lord loh.
Unhappy Locked AVR?

I have run into a problem with my ATmega16 AVR. I was trying to set some fuse bits using AT prog by sending 4 byte serial instructions. What I wanted to do was set the AVR to use the external 16MHz Xtal. but now all I see is "device locked". Is there a way to salvage the avr?

Please let me know of anything that I can refer to recover the ATmega16...


Thanks in advance...
__________________
Bharath Bhushan Lohray.
M.Sc. Electronics.
lord loh. is offline   Reply With Quote
Old 13th April 2008, 09:28 PM   (permalink)
Experienced Member
 
futz is a name known to allfutz is a name known to allfutz is a name known to allfutz is a name known to allfutz is a name known to allfutz is a name known to all
Default

Quote:
Originally Posted by lord loh.
I have run into a problem with my ATmega16 AVR. I was trying to set some fuse bits using AT prog by sending 4 byte serial instructions. What I wanted to do was set the AVR to use the external 16MHz Xtal. but now all I see is "device locked". Is there a way to salvage the avr?

Please let me know of anything that I can refer to recover the ATmega16...
This is one of the major things about AVRs that can be annoying, and that I think PICs do lots better. AVRs need the oscillator running to program, cuz they use SPI to program. PICs need the oscillator NOT RUNNING to program. The clock is provided by the programmer. Seems to be a better way of doing it because you really can't get locked out by silly mistakes (unless you set code protection or something).

I've locked myself out of at least one AVR chip module (Staver 24M32) by being careless.

If you get your AVR fuse bits set wrong you can no longer access the chip unless you remember (or know) exactly what change you made. You have to rebuild your circuit so it matches the change and then you can reprogram it.

If you did successfully program the fuse bits for 16MHz crystal, then put the crystal on the chip and it should work again. But if you managed to program it for some random oscillator type then you could cure it by trying every different osc type till you hit the right one.

If you don't remember what you did then you have to set up your circuit and build a cable to reprogram it using HVSP or HVPP. PICs use the equivalent of HVSP.

The moral of the story is this: Think long and hard about what you're doing before making a fuse bit change on an AVR. Be sure you understand exactly what you're changing and why. Make detailed notes on the changes you make (before you actually make them) so that if things go bad you can refer to the notes and be able to recover.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================

Last edited by futz; 14th April 2008 at 03:37 AM.
futz is online now   Reply With Quote
Old 13th April 2008, 09:49 PM   (permalink)
Super Moderator
 
Nigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to behold
Default

Quote:
Originally Posted by futz
This is one of the major things about AVRs that can be annoying, and that I think PICs do lots better. AVRs need the oscillator running to program, cuz they use SPI to program. PICs need the oscillator NOT RUNNING to program. The clock is provided by the programmer. Seems to be a better way of doing it because you really can't get locked out by silly mistakes (unless you set code protection or something).
Bummer! - I never knew that.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Old 14th April 2008, 06:26 AM   (permalink)
Experienced Member
 
eblc1388 is just really niceeblc1388 is just really niceeblc1388 is just really nice
Default

Quote:
Originally Posted by lord loh.
Please let me know of anything that I can refer to recover the ATmega16...
You can use the High Voltage programming mode on STK500 or Dragon to recover your AVR.
__________________
L.Chung
eblc1388 is offline   Reply With Quote
Old 14th April 2008, 11:25 AM   (permalink)
Experienced Member
 
lord loh. is on a distinguished road
Send a message via Yahoo to lord loh.
Unhappy

What if code protection has accidentally been set?

The ATProg tool is able to read the signature byte of the AVR. It is able to detect that there is an ATmega16 in socket. So it the software is able to communicate with the AVR.

How do i salvage the avr if the lock bits have been set?

Is it normal that signature bits remain readable and the device remains nonprogrammable if the fuse bits such as oscillator is of wrong frequency?

The programming existing in the AVR runs though...
__________________
Bharath Bhushan Lohray.
M.Sc. Electronics.
lord loh. is offline   Reply With Quote
Old 14th April 2008, 12:19 PM   (permalink)
Experienced Member
 
eblc1388 is just really niceeblc1388 is just really niceeblc1388 is just really nice
Default

Quote:
Originally Posted by lord loh.
How do i salvage the avr if the lock bits have been set?
Try to perform an erase operation on the AVR fuses bits from the porgramming software.

The erase command can return the lockbits to the unprogrammed state but also will erase the content of the AVR flash memory.
__________________
L.Chung
eblc1388 is offline   Reply With Quote
Old 14th April 2008, 01:13 PM   (permalink)
Experienced Member
 
lord loh. is on a distinguished road
Send a message via Yahoo to lord loh.
Unhappy it does not work...

I see the "device Locked!" message when I try an erase operation as well...
__________________
Bharath Bhushan Lohray.
M.Sc. Electronics.
lord loh. is offline   Reply With Quote
Old 14th April 2008, 02:46 PM   (permalink)
Experienced Member
 
eblc1388 is just really niceeblc1388 is just really niceeblc1388 is just really nice
Default

Quote:
Originally Posted by lord loh.
I see the "device Locked!" message when I try an erase operation as well...
Did you use "two resistors + parallel printer port + ATProg software" setup to try to program the Mega16?
__________________
L.Chung

Last edited by eblc1388; 14th April 2008 at 04:16 PM.
eblc1388 is offline   Reply With Quote
Old 14th April 2008, 05:52 PM   (permalink)
Experienced Member
Salgat is a jewel in the roughSalgat is a jewel in the rough
Send a message via AIM to Salgat Send a message via MSN to Salgat Send a message via Skype™ to Salgat
Default

I believe you have to use High Voltage Programming to erase the Lock Bits, which also includes erasing everything else. High Voltage programming requires 12 volts, so if you are using the STK500 you will need to follow the wiring guide provided under the help section of the AVR Studio in order to setup high voltage programming.
__________________
salgat.blogspot.com
Salgat is offline   Reply With Quote
Old 14th April 2008, 07:11 PM   (permalink)
Experienced Member
 
futz is a name known to allfutz is a name known to allfutz is a name known to allfutz is a name known to allfutz is a name known to allfutz is a name known to all
Default

Quote:
Originally Posted by Salgat
I believe you have to use High Voltage Programming to erase the Lock Bits, which also includes erasing everything else. High Voltage programming requires 12 volts, so if you are using the STK500 you will need to follow the wiring guide provided under the help section of the AVR Studio in order to setup high voltage programming.
The Dragon will do HVSP and HVPP too. As long as it's possible to get all the necessary lines connected for high voltage programming then it's just like programming a PIC.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is online now   Reply With Quote
Old 14th April 2008, 07:38 PM   (permalink)
Experienced Member
 
eblc1388 is just really niceeblc1388 is just really niceeblc1388 is just really nice
Default

Quote:
Originally Posted by Salgat
I believe you have to use High Voltage Programming to erase the Lock Bits,...
Note that I'm aware of? Can you provide any reference to it?

If one has disabled the SPIEN feature, then High voltage programming is a must to restore the AVR.

On some AVRs, there is an option to allocate the RESET pin as I/O. This will also means HVP is required to restore the AVR because ISP needs the reset pin to function.

Other than those situations, I think a normal low voltage ISP can perform an chip erase operation to reset the lock bits.
__________________
L.Chung
eblc1388 is offline   Reply With Quote
Old 15th April 2008, 10:01 AM   (permalink)
Experienced Member
 
eblc1388 is just really niceeblc1388 is just really niceeblc1388 is just really nice
Default

I just tried an experiment to see if I can erase the AVR after I have set the lockbits.

Using AVRISP, via COM1 port, but I did it on a Tiny2313 instead.

1. I set the AVR lockbits, programmed the lockbits and read back the lockbits. They match.

2. Reading AVR flash. Got mostly gibberish bytes(AVR is protected).

3. Perform a chip erase. OK.

4. Read back lockbits. Now all lockbits are cleared(unlocked).

5. Reprogram the AVR. OK.
__________________
L.Chung
eblc1388 is offline   Reply With Quote
Old 15th April 2008, 02:34 PM   (permalink)
Experienced Member
 
futz is a name known to allfutz is a name known to allfutz is a name known to allfutz is a name known to allfutz is a name known to allfutz is a name known to all
Default

Quote:
Originally Posted by eblc1388
OK.
Excellent. I was unsure about that.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is online now   Reply With Quote
Old 17th April 2008, 05:11 PM   (permalink)
Experienced Member
 
lord loh. is on a distinguished road
Send a message via Yahoo to lord loh.
Default The Programmer.

to eblc1388: Yes, I was using the two resistor, parallel port programmer to programe my ATmega16. The question of using st500/ avr dragon does not arise as I do nt have them... All I will have to do is build a few of my own parallel programmer circuits...

I am mighty releaved to know that the AVR can be salvaged and is not deadlocked.... :-)

by the way, are there ways to get an AVR into a dead-lock?
__________________
Bharath Bhushan Lohray.
M.Sc. Electronics.
lord loh. is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
AVR InfraRed Remote code capture project eblc1388 Micro Controllers 14 12th April 2008 06:49 PM
What is a good AVR programmer with debug & HV programming? blueroomelectronics Micro Controllers 19 13th March 2008 01:53 AM
CodeVision AVR Help hitusharpatil Micro Controllers 12 22nd January 2008 04:09 AM
Eclipse IDE for ARM, AVR, and PIC? linuxguy Micro Controllers 9 29th September 2007 05:13 PM
learning phase locked loops Kurupt General Electronics Chat 1 27th January 2005 02:04 AM



All times are GMT. The time now is 11:40 PM.


Electronic Circuits  |  Radio Controlled
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.