Help in dumping program onto Atmega16 using USBASP

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

Hello all

 

I bought my first Atmega 16 yesterday and I want to transfer my first program from my PC to the controller. For this purpose I am using USBASP Programmer. The link for specific model I am using  is https://robu.in/product/usbasp-a....

 

I have read the manual and the procedure to dump the code. However, I am read in many forums about the wrong fuse settings that newbies like me make which makes the controller unusable. Thus I want to confirm that my fuse settings are correct beforehand. After reading the datasheet, I got the fuse settings when external oscillator is connected as lfuse = 0xff and hfuse = 0xC9. Let me know if I am correct. Also let me know what are the fuse settings when Internal oscillator is used.

 

Finally, according to the youtube tube given in the programmers site we need to connect only MOSI, MISO, SCK, RESET, VCC and GND. However in atmega 16 datasheet it is given that AVCC and another GND at pin 31 should also be connected. So do I have to connect AVCC and GND to that of VCC and GND of the programmer?

 

Regards

shrishailan Srinidhi

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

When you say "external oscillator", is it really an oscillator or "just" a crystal?

 

Most crystals have two pins and work with a little amplifier inside the MCU to create a complete oscillator. Some resonators (which function fairly much like crystals) have 3 pins.

 

An external oscillator typically has 4 pins and requires a power connection to make it work. It makes a clock signal whether or not it is even connected to a micro. This makes it a "stand alone" device. 

 

The fuse settings are quite different. There is one for "External Oscillator" and maybe several for "External Crystal or Resonator". If you use the External Oscillator fuse setting with a crystal or resonator, you have made yourself a very un-useful little brick.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

drmius wrote:
However in atmega 16 datasheet it is given that AVCC and another GND at pin 31 should also be connected. So do I have to connect AVCC and GND to that of VCC and GND of the programmer?
In theory yes though in reality, for simple experiments, you will probably get away with just single Vcc+Gnd. Note however that AVCC is effectively the power supply for PORTA (the analog pins) so you may have problems if you don't connect it then try to use that port.

 

(BTW I suppose it's too late now but for the same money a USBAsp and a standalone mega16 cost you probbaly could have got one of the cheap Arduino clones which is a full circuit with things like power and crystal connections already sorted out).

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

It is a crystal. It has 2 pins.

shrishailan Srinidhi

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

Is it below or above 8Mhz? Below you don't need "CKOPT", above you do. (though it doesn't hurt to enable it even if not needed - so perhaps safest).

 

Putting that into http://www.engbedded.com/fusecalc/ but leaving all other settings at default I get Low:0xFF, High: 0x89

 

That is almost the same as you except for 0xC9 versus 0x89. As I said I left all others at default but your 0xC9 suggest you are deactivating JTAGEN. Are you sure you want to do that? I personally would always use JTAG when it's available (and for mega16 you can use a $5..$10 JTAG interface). If you want to disable JTAG you can always do it in code anyway with the double write to the JTD bit.

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

Thanks. Correct me if I am wrong: for internal 1Mhz clock it is lfuse : E1 and hfuse : 89?

shrishailan Srinidhi

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

Well Engbedded says that the default fuses for mega16 are 0xE1, 0x99 (the difference between that and what you just said is that by default CKOPT is not enabled - if using "internal" then CKOPT is pointless)

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

In theory yes though in reality, for simple experiments, you will probably get away with just single Vcc+Gnd. Note however that AVCC is effectively the power supply for PORTA (the analog pins) so you may have problems if you don't connect it then try to use that port.

The problem with not connecting AVCC is that it will still get power, but through the protection diodes on that pin.  Those are rated for no more than about 1mA continuous, so any attempt to drive PORTA pins as outputs will tend to kill one of those diodes.  It will also result in a large voltage drop on those pins, and on AVCC.  What's more, if you have BOD enabled, it monitors AVCC as well as VCC, so as the voltage drop on AVCC wanders into and out of the BOD threshold, the device will experience BOD resets.  Can be quite hard to troubleshoot.

 

The moral:  Always connect AVCC.  Always.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]