HOOMAN ASGARI
HOOMAN ASGARI

Reputation: 19

I'm new to avr. cant program it

I've written code below for a flasher led! in CodeVision as my first program!! with ATmega16.

but I can't program it with extreme burner.CodeVision compiles it with 0 errors and 0 warnings. Extreme burner loads the .hex file successfully. But when I click on the Read all button, I can't continue. I see this report: powering on => power on failed => can not communicate with target chip. and at in the end I got this message: No data read!

I don't know what is correct the value of fuse bits and how to set them correctly.

#include <mega16.h>
#include <delay.h>
void main(void)
{
  PORTA=0x00;
  DDRA=0x01;
  while (1)
  {
    PORTA.0 = 1;
    delay_ms(200);
    PORTA.0 = 0;
    delay_ms(500);
  }
}

Upvotes: 1

Views: 2683

Answers (4)

Lalith Buddhika
Lalith Buddhika

Reputation: 11

New chips need slow programming.there is mode in usbasp to do that.then use new fusebit setting and write them with slow.then you will be able to use normal

Upvotes: 1

Chebhou
Chebhou

Reputation: 148

the problem is not in the coding / compiling process . the error you got indicates that the programmer is recognized and it's working , and that leaves you with the following possible problems :

  1. the connection between the the programmer and the chip ,

    • 6 wires : VCC->VCC ,GND->GND ,CLK->CLK , RESET->RESET, MOSI->MOSI, MISO->MOISO. if still not working try reversing the last two wires .
  2. the chip has been programmed before and it won't operate without external crystal .

    • connect a crystal to the XTAL pins with two 22pF ceramic capacitors, try different crystal values : 8,4,1 or less .
  3. if you can change the programmer speed set it to the slowest. "Usbasp has a jumper for slow devices programming , check your programmer guide ".

  4. try different chip if available .

Upvotes: 2

Funkyguy
Funkyguy

Reputation: 620

It looks like your problem lies with the ATmega16 simply not being powered up. Keep in mind that your programmer specifically applies power to the target, then you need to power it yourself. This can be a problem with many cheap development boards.

While it is weird that you are pressing Read all rather than Program or Write or whatever your programming program would have, this error would have popped up either way considering the issue.

To find out if it is powered, generally a development board will have a power LED but in case you don't have that kind of indication, check with a multimeter on the VCC and GND pins of the atmega16. From the picture below, you can see that you could check those pins at pin 10 and 11, but I would recommend checking rather at pin 10 and 31 to avoid shorting them together by accident.

enter image description here

If it turns out that your device is powered on, then you do need to check your SPI connections as the AVR is programmed through the SPI port. If they are connected just fine, you can check to see if they are actually sending data by using a logic analyzer. If they aren't sending data, then you have a problem with your actual programmer

If it turns out that those are fine and functional, then I would bet that your Atmega16 is faulty or counterfeit.

Upvotes: 2

vlad_tepesch
vlad_tepesch

Reputation: 6891

why do you want to "Read All"? i thought your intention is to program your device and not to read out its memories.

But your true problem is the connection to the device is not working. look at the manual or tutorial of your programming adapter on how to use it.

The following (incomplete) list may contain the most common errors:

  • OS driver of your programmer is not correctly installed/Your OS have not recognized it correctly
  • The ISP interface of the device is not correctly connected to your Programmer
    • MISO - MISO, MOSI - MOSI, CLK - CLK, GND - GND, RESET - RESET, VCC - VCC
    • recheck it. maybe your wiring scheme was looking from wrong/another side on the connector (plug front vs. plug back vs pin header top).
  • VCC connection to programmer does not mean that it will power the device. this is programmer dependend. some (this may be the better designed ones) only use VCC connection to determine the targets voltage leves to correctly setup the data signal lines. So you may separately have to power the device
  • programmers speed is set to high. new AVRs are set to 1Mhz that is to slow for the higher ISP data rates.
  • You accidently misconfigered the AVR fuse bits so it is not reachable anymore. You may have mess up the clock settings.

Upvotes: 1

Related Questions