Messing with fuse bits on the ATMega 16 Controller

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

Hello

I am using the Pony programmer and ATMega16 controller and I've bin messing with the clock select fuse bits. I am using an 8 MHz crystal and have set up the fuse bits according to the data sheet which says if you have a 3.0 - 8.0 MHz crystal resonator you ought to set CKSEL3 ... CKSEL1 to some combination ( 111 worked for me pretty fine ), but then I have by accident set also CKSEL0 to 1 and since than i can not read or write to my controller. So my question is, is there any way that i could re program those fuse bits to a previous state CKSEL3 ... CKSEL1 = 111 and CKSEL0 = 0

thanx in advance

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

Let your micro mega16 rest in the heaven.... There is no way out now....

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

damn feared so :( ... thanks for your answer

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

I did not look up the CKSEL bits in the datasheet but the OP "sounds" like (I could have misread) the fuses are set for external oscillator instead of external crystal/resonator. The mega16 "should" be able to be revived by connecting some sort of logic level clock signal to the XTAL1 pin of the mega16. I have seen reports here of people using 500kHz to around 1MHz. Just make sure to lower the ISP frequency to something 1/4 or less of whatever frequency you are feeding into the XTAL1 pin.

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

Thanks Steven I'll surely give it a try

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

You might find this useful too: http://palmavr.sourceforge.net/c...

Looking at that it appears you have programmed it for an external oscillator and SteveN's suggestion should work.

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

yellowboy_75 wrote:
Let your micro mega16 rest in the heaven.... There is no way out now....

Why on earth would you say that? If all that's happened is a CKSEL "accident" then all that's required is to pump a square wave into XTAL1 for an ISP session to get the fuses set back correctly. In fact HVPP will generally get most AVRs out of any kind of fuse "hole".

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

Hey guys I have managed to "bring back to life" mi MEGA16. I've found a nice trick on google ( something StevenN mentioned also ). I've programmed another Mega16 to act as a 1Mhz logic oscilator and connected the output of that Mega16 to the XTAL1 pin of my "broken" Mega. In ISP mode i've read the fuse bits and reprogrammed them to their previous state. So now I have two functional Mega's. I must be a really rich guy :-D. Thanks anyone for very much helpfull hints :-)

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

Thanks for reporting back. Too many times people request help here, are given decent answers and then we never hear which answer worked. That makes it tough for people searching the forums to find definitive answers.

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

Hello.
I have the same problem. I do not understand how KaktusJack is repeat the MEGA16. Can you give me information how I reading and reprograming fuso bits after I connecting another MEGA16 to XTAL1?
PP: And how I program "working" MEGA16, so that it generate 1 MHz

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

First you should tell us what kind of programmer you use to programmer your microcontrollers, I for example use Pony programmer. Here's the sample code I used to generate a 1MHz signal

.include "m16def.inc"

.cseg
.org 	0x00
rjmp	main


main:
		ldi		r16,0xFF
		out		DDRD,r16

loop1:
		cpi		r17,0x08
		breq 	loop2
		ldi		r16,0xff;
		out 	PORTD,r16
		inc		r17
		rjmp	loop1

loop2:
		cpi 	r17,0x00
		breq 	loop1
		ldi		r16,0x00
		out		PORTD,r16
		dec		r17
		rjmp 	loop2  

And the other MEGA16 which I programmed this code was set up to work on the 1MHz internal oscilator ( I think that all MEGA16 are initially set up to use the internal 1MHz oscilator )

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

I use this http://www.lancos.com/e2p/si-pro... programmer. Thank you for the code. I don't know whether my programmer is ISP or it isn't?
I will buy new MEGA tomorrow and I will test it

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

Yep its ISP and I use the same software as you I think, namely the Pony Programmer, good luck with your MEGAs :)

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

I don't have success...
When I write the code in "worked" mega and I measure frequency with multimeter - it is 8.58 KHz! "Worked" atmega16 may work on 1MHz. I add pictures on the fuse bits.

Attachment(s): 

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

Working, Working....
I set new mega to 8 MHz internal oscillator and use this code

#include 

void main(void)
{
	DDRD = 0xff;
	PORTD = 0xff;

	while(1)
	{
		PORTD = PORTD;
		PORTD = ~PORTD;
	}
}

Thanks to everybody

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

really glad it worked :)

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

KrisBG wrote:
I use this http://www.lancos.com/e2p/si-pro... programmer. Thank you for the code. I don't know whether my programmer is ISP or it isn't?
I will buy new MEGA tomorrow and I will test it

Understanding of which programmer is ISP or not is quite simple.
If it uses only SCK MISO MOSI & RESET pin on the target then it could be considered ISP.. Actually ISP stands for In System Programming which means you don't need to unplug your chip and plug it to the programmer, insert it back to your app circuit each time you want to program it. Therefore using ISP you could just add few header pins on your app circuit to connect an ISP programmer each time you want to program it.

KISS - Keep It Simple Stupid!