Problem with lecture 2 - no communication with atmega168

Hello.

I have found no solution to this problem. I’m using win xp with a Parallel Cable DB25 M/F - 6 Foot, that followed the kit.

> "make.exe" program
avrdude -p atmega168 -P lpt1 -c stk200    -U flash:w:blink_1MHz.hex 

avrdude: AVR device not responding
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

make.exe: *** [program] Error 1

> Process Exit Code: 2
> Time Taken: 00:03

The code is the same from the sample in the tutorial. My makefile is set to:

AVRDUDE_PROGRAMMER = stk200
#AVRDUDE_PROGRAMMER = ponyser

# com1 = serial port. Use lpt1 to connect to parallel port.
AVRDUDE_PORT = lpt1
#AVRDUDE_PORT = COM1

As far as I know, I have connected the ISP correctly:

http://stilen.net/media/breadboard.jpg

I’ve also testet the communication with PonyProg, using Read All, and it says: Device missing or unknown device (-24).

When I choose ignore, it reads 16896 bytes, but the hex file is empty (a lot of FF FF FF FF).

My interface setup is Parallel, Avr ISP I/O LPT1.

My system is setup at:

http://stilen.net/media/box1.jpg

Now, my breadboard. 4.8V to the reset input at pin 1. 5V everywhere else to my atmega168. I did have a switch at the reset line, but I removed it.

Why isn’t this working?

/*
    5-10-07
    Copyright Spark Fun Electronics© 2007
    Nathan Seidle
    nathan at sparkfun.com
    
    ATmega168
	
	Example Blink
	Toggles all IO pins at 1Hz
*/

#include <avr/io.h>

//Define functions
//======================
void ioinit(void);      //Initializes IO
void delay_ms(uint16_t x); //General purpose delay
//======================

int main (void)
{
    ioinit(); //Setup IO pins and defaults

    while(1)
    {
		PORTC = 0xFF;
		PORTB = 0xFF;
		PORTD = 0xFF;
		delay_ms(500);

		PORTC = 0x00;
		PORTB = 0x00;
		PORTD = 0x00;
		delay_ms(500);
    }
   
    return(0);
}

void ioinit (void)
{
    //1 = output, 0 = input
    DDRB = 0b11111111; //All outputs
    DDRC = 0b11111111; //All outputs
    DDRD = 0b11111110; //PORTD (RX on PD0)
}

//General short delays
void delay_ms(uint16_t x)
{
  uint8_t y, z;
  for ( ; x > 0 ; x--){
    for ( y = 0 ; y < 90 ; y++){
      for ( z = 0 ; z < 6 ; z++){
        asm volatile ("nop");
      }
    }
  }
}

And, an image from above:

http://stilen.net/media/breadboard2.jpg

I’ve also tried adding a delay in the command input, with no result. And I’m sure the atm is right, as there is an arrow pointing to input 1.

I’ve also read about people adding a crystal. But why should this be necessary, when it wasn’t necessary in lecture 2? And also, I have no idea where to setup this crystal, tho I have bought a crystal that came in later lectures.

So, any advice would be helpful.

haha… I found the problem. lol

I hadn’t pushed the atm hard enough down to the breadboard! I’ve spent hours trying to figure out what’s wrong. Finally it works. :slight_smile: