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