Programing babyO b-48

Hello
I am using ubuntu 9.04 and I tried to program my new baby 0 B-48 and i got the following error:

arbel@arbel:~/Desktop/bascketball$ sudo make
/usr/bin/avrdude -c avrispmkII -p m48 -P usb -e

avrdude: stk500v2_command(): command failed
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

make: *** [program] Error 1

I am able to program my old baby o (the green one)

after I get this error, the red led on my programmer starts to blink fast (my programmer is an avrispmkII)

every thing seems to be connected in the right way, when I connect the programmer both the leds are green. when I enter the MAKE command the red led blinks.

This is my makefile:

CC=/usr/bin/avr-gcc
MEGA=48
CFLAGS=-g -Os -Wall -mcall-prologues -mmcu=atmega$(MEGA)
OBJ2HEX=/usr/bin/avr-objcopy 
PROG=/usr/bin/avrdude
TARGET=bascketball

program : $(TARGET).hex
	$(PROG) -c avrispmkII -p m$(MEGA) -P usb -e
	$(PROG) -c avrispmkII -p m$(MEGA) -P usb -U flash:w:$(TARGET).hex

%.obj : %.o
	$(CC) $(CFLAGS) $< -o $@

babyO.obj : $(TARGET).o pwm.o servo.o
	$(CC) $(CFLAGS) $(TARGET).o pwm.o servo.o -o $@

%.hex : %.obj
	$(OBJ2HEX) -R .eeprom -O ihex $< $@

clean :
	rm -f *.hex *.obj *.o[/code]

this is my code:

// F_CPU tells util/delay.h our clock frequency

//#define F_CPU 8000000UL   // Orangutan frequency (8MHz)

#define F_CPU 20000000UL   // Baby Orangutan frequency (20MHz)

#include <avr/io.h>

#include <util/delay.h>

#include "device.h"


void delayms( uint16_t millis ) {

   while ( millis ) {

      _delay_ms( 1 );

      millis--;

   }

}

void display_init (){
	//define all the segment ports as output.   
	DDRB |= 1 << PB0; //A segment
	DDRB |= 1 << PB1; //B segment
	DDRB |= 1 << PB2; //C segment
	DDRB |= 1 << PB4; //D segment
	DDRB |= 1 << PB5; //E segment
	DDRD |= 1 << PD0; //F segment
	DDRD |= 1 << PD1; //G segment
	DDRD |= 1 << PD2; //common GND
	DDRD |= 1 << PD4; //common GND
	DDRD |= 1 << PD7; //common GND
	//turn all segments off
	//PORTB |= 1 << PB0; // A segment off
	//PORTB |= 1 << PB3; // B segment off
	//PORTB |= 1 << PB4; // C segment off
	//PORTB |= 1 << PB5; // D segment off
	//PORTD |= 1 << PD0; // E segment off
	//PORTD |= 1 << PD1; // F segment off
	//PORTD |= 1 << PD2; // G segment off

}

void clean_all (){
//turn all segments off
	PORTB |= 1 << PB0; // A segment off
	PORTB |= 1 << PB1; // B segment off
	PORTB |= 1 << PB2; // C segment off
	PORTB |= 1 << PB4; // D segment off
	PORTB |= 1 << PB5; // E segment off
	PORTD |= 1 << PD0; // F segment off
	PORTD |= 1 << PD1; // G segment off	 
}

void display_one (){
	
	//display one
	PORTB &= ~( 1 << PB1 ); // B segment on
	PORTB &= ~( 1 << PB2 ); // C segment on
	PORTB |= 1 << PB0; // A segment off
	PORTB |= 1 << PB4; // D segment off
	PORTB |= 1 << PB5; // E segment off
	PORTD |= 1 << PD0; // F segment off
	PORTD |= 1 << PD1; // G segment off	 
}

void display_two (){
	PORTB &= ~( 1 << PB0 ); //A segment on
	PORTB &= ~( 1 << PB1 ); // B segment on
	PORTD &= ~( 1 << PD1 ); // G segment on
	PORTB &= ~( 1 << PB5 ); // E segment on
	PORTB &= ~( 1 << PB4 ); // D segment on
	PORTB |= 1 << PB2; // C segment off
	PORTD |= 1 << PD0; // F segment off
}

void display_three (){
	PORTB &= ~( 1 << PB0 ); //A segment on
	PORTB &= ~( 1 << PB1 ); // B segment on
	PORTD &= ~( 1 << PD1 ); // G segment on
	PORTB &= ~( 1 << PB2 ); // C segment on
	PORTB &= ~( 1 << PB4 ); // D segment on
	PORTB |= 1 << PB5; // E segment off
	PORTD |= 1 << PD0; // F segment off
}

void display_four (){
	PORTD &= ~( 1 << PD0 ); // F segment on
	PORTB &= ~( 1 << PB1 ); // B segment on
	PORTD &= ~( 1 << PD1 ); // G segment on
	PORTB &= ~( 1 << PB2 ); // C segment on
	PORTB |= 1 << PB0; // A segment off
	PORTB |= 1 << PB4; // D segment off
	PORTB |= 1 << PB5; // E segment off
}

void display_five (){
	PORTB &= ~( 1 << PB0 ); //A segment on
	PORTD &= ~( 1 << PD0 ); // F segment on
	PORTD &= ~( 1 << PD1 ); // G segment on
	PORTB &= ~( 1 << PB2 ); // C segment on
	PORTB &= ~( 1 << PB4 ); // D segment on
	PORTB |= 1 << PB1; // B segment off
	PORTB |= 1 << PB5; // E segment off
}

void display_six (){
	PORTB &= ~( 1 << PB0 ); //A segment on
	PORTD &= ~( 1 << PD0 ); // F segment on
	PORTD &= ~( 1 << PD1 ); // G segment on
	PORTB &= ~( 1 << PB5 ); // E segment on
	PORTB &= ~( 1 << PB4 ); // D segment on
	PORTB &= ~( 1 << PB2 ); // C segment on
	PORTB |= 1 << PB1; // B segment off
}

void display_seven (){
	PORTB &= ~( 1 << PB0 ); //A segment on
	PORTB &= ~( 1 << PB1 ); // B segment on
	PORTB &= ~( 1 << PB2 ); // C segment on
	PORTB |= 1 << PB4; // D segment off
	PORTB |= 1 << PB5; // E segment off
	PORTD |= 1 << PD0; // F segment off
	PORTD |= 1 << PD1; // G segment off	 
}

void display_eight (){
	PORTB &= ~( 1 << PB0 ); //A segment on
	PORTB &= ~( 1 << PB1 ); // B segment on
	PORTB &= ~( 1 << PB2 ); // C segment on
	PORTB &= ~( 1 << PB4 ); // D segment on
	PORTB &= ~( 1 << PB5 ); // E segment on
	PORTD &= ~( 1 << PD0 ); // F segment on
	PORTD &= ~( 1 << PD1 ); // G segment on
}

void display_nine (){

	PORTB &= ~( 1 << PB0 ); //A segment on
	PORTB &= ~( 1 << PB1 ); // B segment on
	PORTB &= ~( 1 << PB2 ); // C segment on
	PORTB &= ~( 1 << PB4 ); // D segment on
	PORTD &= ~( 1 << PD0 ); // F segment on
	PORTD &= ~( 1 << PD1 ); // G segment on
	PORTB &= ~( 1 << PB5 ); // E segment on
	
}

void display_zero (){
	PORTB &= ~( 1 << PB0 ); //A segment on
	PORTB &= ~( 1 << PB1 ); // B segment on
	PORTB &= ~( 1 << PB2 ); // C segment on
	PORTB &= ~( 1 << PB4 ); // D segment on
	PORTB &= ~( 1 << PB5 ); // E segment on
	PORTD &= ~( 1 << PD0 ); // F segment on
	PORTD |= 1 << PD1; // G segment off 
}


void display (int number){
	switch (number){
	case 0: display_zero (); break;
	case 1: display_one (); break;
	case 2: display_two (); break;
	case 3: display_three (); break;
	case 4: display_four (); break;
	case 5: display_five (); break;
	case 6: display_six (); break;
	case 7: display_seven (); break;
	case 8: display_eight (); break;
	case 9: display_nine (); break;
	}
		
}


int main( void ) {

display_init ();
	PORTD |= 1 << PD2;//enable display
	for(;;)
	{
	PORTB &= ~( 1 << PB0 ); //A segment on
	delayms(500);
	PORTB &= ~( 1 << PB1 ); // B segment on
	delayms(500);
	PORTB &= ~( 1 << PB2 ); // C segment on
		delayms(500);
	PORTB &= ~( 1 << PB4 ); // D segment on
		delayms(500);
	PORTB &= ~( 1 << PB5 ); // E segment on
		delayms(500);
	PORTD &= ~( 1 << PD0 ); // F segment on
		delayms(500);
	PORTD &= ~( 1 << PD1 ); // G segment on
		delayms(500);
	}
}

Thanks
Arbel

Hello.

So you’re saying that if you repeat your procedure exactly using your other Baby Orangutan, it works as expected, but it fails on your new Baby Orangutan? Have you ever successfully programmed your new Baby Orangutan B-48?

My first suggestion would be to check the solder connections between the programming header and the board.

- Ben

No, it’s my first try with the new babyO . The connections look OK, the ohmmeter shows no shirt circuit. what else can I check?
Arbel

Can you post a somewhat high-resolution picture of the ISP header solder joints? And you didn’t answer my question:

If you perform the same procedure on both boards, are you saying that it works with your original Baby O but not your new Baby O?

- Ben

Something happend. when I disconnected every thing from the board it did program. but when it is connected to the leds (I an trying to work a 7 segment displey) I couldn’t program. I would say that thats good news no?
how do I program it when it is conected?

BTY
I didn’t do the same thing becuase I had to change the makefile from 168 to 48…
Arbel

Arbel,

You should have mentioned that you have external components connected to the board; that is much more relevant than the code you’re trying to program.

You should not connect anything to the Baby Orangutan’s SPI lines that might interfere with programming. In general, I recommend you avoid using pins PB4 and PB5 unless you can be sure you’re using them in a way that won’t prevent the SPI communication needed to program the device.

Do the LEDs in your seven-segment displays have integrated current-limiting resistors? If not, are you using external current-limiting resistors?

- Ben

By current restrictions do you mean resistors? I am not using them and I don’t know if my display has them on board. (I can’t find their data sheet on the net…) but I think thay don’t have that. should I use resistors? what should their value be?
I didn’t mentioned that I had things connected to the babyO beacuase with my old baby O I could program it with things connected to it so I didn’t think it was that.
Arbel

The pinout differs between the original Baby Orangutan and the Baby Orangutan B, so it’s possible that you weren’t making connections to the programming pins PB4 and PB5 on your original Baby O. Do you have the ability to avoid connecting components to PB4 and PB5 in your new design? Can you program the board if you do this?

The reason I asked about current-limiting resistors is because if you leave them out and the device you’re using doesn’t have them internally, you are effectively shorting your output pins to ground through the LED. This could explain why you cannot program the device when you’re using pins PB4 and PB5. I can’t give you too much advice without seeing the datasheet for your seven-segment display, but a typical current limiting resistor is between 100 and 1k. If you have a multimeter, you can look at your pin output voltage while it’s driving the segment LED to see if you need one. If the pin is at 5V, you probably don’t need a resistor. You can also try using your multimeter to measure the resistance between one of your seven-segment display’s LED inputs and ground.

- Ben