avrdude and the atmega8u2

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

Does anybody have a patch (or a workaround) that will let me use avrdude with the atmega8u2?

I just downloaded version 5.10 and don't see it in the supported parts list....

Thanks!

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

update: I just talked to Dean on Skype and he says to try -F'ing it with the AT90USB162 profile. I'll try it tomorrow and report back.

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

-F'ing it, eh. :P

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

Err, I meant use the -F switch to disable the signature check :P. The at90usb162 and at90usb82 are binary compatible, the latter just has more memory (FLASH, SRAM and EEPROM). Quite odd that it's not an officially supported AVR model in avrdude, however.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

it worked! thanks dean!

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

hello, I'm very new to this and just encountered the same problem.

avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for AT90USB162 is 1E 94 82

avrdude done.  Thank you.

is this the response I want?
when I try to flash I get:

avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for AT90USB162 is 1E 94 82
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed

         To disable this feature, specify the -D option.

avrdude done.  Thank you.
avrdude -c usbtiny -p usb162 -F -U flash:w:testm8u2.hex
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No. 'Yikes' is not a good response.

Check your wiring.
Check you have a good clock.

David.

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

thanks for the quick reply, david.
And even thought english is not my native language I, as well, got the feeling "yikes" was bad :)

I've spend the afternoon reading the datasheet and I can't find anything I've missed.
I connect my programmer according to the Serial Programming Pin Instructions (page 259, datasheet: http://www.atmel.com/dyn/resources/prod_documents/doc7799.pdf), and have no external clock. Have nothing else connected than those 7 pins.

edit: bad link

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

No. I have not checked your AT90USB162 data sheet, but I seem to remember Dean saying that the USB chips come out of the factory different to regular AVRs.

e.g. they may expect to have a crystal.

It is your data sheet, so you can look it up.

If this is the reason, supply an external clock or crystal.

David.

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

Quote:
8.3.1Default Clock Source
The device is shipped with internal RC oscillator at 8.0 MHz and with the fuse CKDIV8 pro-
grammed, resulting in 1.0 MHz system clock. The startup time is set to maximum and time-out
period enabled. (CKSEL = "0010", SUT = "10", CKDIV8 = "0"). The default setting ensures that
all users can make their desired clock source setting using any available programming interface.

Not sure I read it right, but as I get it it's fused as internal clock, 1Mhz

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

It absolutely needs an external 8MHz or 16MHz crystal (I believe the bootloader autodetects this) despite what the datasheet says. At the factory when they load in the bootloader they change the fuses to an external crystal so that the USB bootloader can work.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

Yeap, a crystal solved it.
Thanks alot guys!

Thinking back, where would I have found that they changed to external clock when installing the bootloader?

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

Only by reading Dean's posts.

I had always assumed that all AVRs came out of the factory as 1MHz RC.

David.

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

Quote:

came out of the factory as 1MHz RC

[pedant=on]
Except the ones that have a 9.6MHz osc div 8 = 1.2MHz
[pedant=off]

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

Quote:
Can anybody help me out with this simple code I have written for RTC. Me and my mentor went over the datasheet of DS1307 & 328p but the status code for addressing the DS1307 remains 00. ANy help anybody ?

#define F_CPU 1000000UL		//	1MHz
//#define F_CPU 8000000UL
#define F_SCL 50000UL		//	50kHz

/*-------------------------------------------*/

#include
#include

//	Definitions for all states of i2c in 168

//		7	 6	 5	    4	 3	  2	   1   0
//	|TWINT|TWEA|TWSTA|TWSTO|TWWC|TWEN|---|TWIE

#define link_start	0xA4
#define link_send	0x84
#define link_stop	0x94
#define link_ACK	0xC4
#define link_NACK	0x84
//#define link_ready	(TWCR & (1<<TWINT))
//#define link_status	(TWSR & 0xF8)

//	Definitions for all registers in RTC

#define DS1307 	0xD0

#define seconds 0x00
#define minutes 0x01
#define hours	0x02

//	function declarations

void mcu_init(void);
void i2c_init(void);
void ser_init(void);

void usart_tx(uint8_t);

void i2c_write_time(uint8_t, uint8_t, uint8_t);
void date_time(void);
void time(void);

uint8_t read_time(uint8_t, uint8_t);

//	function declarations for i2c operations

char i2c_start(void);
char i2c_send(uint8_t);
void i2c_stop(void);
char i2c_write(uint8_t);
char i2c_NACK(void);

uint8_t link_status;

int main(void)
{
	ser_init();
	mcu_init();
	i2c_init();

	usart_tx(0xCC);

//	set default time 00:00:00 -- time being

	i2c_write_time(DS1307, seconds, 00);
//	usart_tx(0x00);

	i2c_write_time(DS1307, minutes, 00);
//	usart_tx(0x00);
	
	i2c_write_time(DS1307, hours,	00);
//	usart_tx(0x00);

	while(1)
	{
		date_time();
		_delay_ms(1000);
		usart_tx(0xAA);
		usart_tx(0xDD);
	}	
}

void mcu_init(void)
{
	DDRB = 0xFF;
	DDRC = 0x00;
}

void i2c_init(void)
{
	TWSR = 0;
	TWBR = (((F_CPU/F_SCL)-16)/2);
	TWCR = (1<<TWEN);
	usart_tx(TWBR);
}

void ser_init(void)
{
	UCSR0B=0x18;	//	enable transmitter and receiver
	UCSR0C=0x36;	//	8DATA BBITS 1 STOP BIT AND ASYNC MODE

	UBRR0=0x000C;	//	4800bps for 1MHz
//	UBRR0=0x0067;	//	4800bps	for 8MHz
	UCSR0A=0x02;	//	DOUBLE SPEED
}

void usart_tx(uint8_t data)
{
	while(!(UCSR0A & (1<<UDRE0)));
	UDR0 = data;

	while(!(UCSR0A & (1<<TXC0)));
	UCSR0A |= (1<<TXC0);
}

void i2c_write_time(uint8_t dev_addr, uint8_t dev_regs, uint8_t dev_data)
{
	i2c_start();
	i2c_send(dev_addr);
	i2c_write(dev_regs);	//	set register to be written
	i2c_write(dev_data);	//	write the register
	i2c_stop();
}

void date_time(void)
{
	time();
}

void time(void)
{
	uint8_t screen;

	screen = read_time(DS1307,hours);
	usart_tx(screen);
	usart_tx(':');

	screen = read_time(DS1307,minutes);
	usart_tx(screen);
	usart_tx(':');

	screen = read_time(DS1307,seconds);
	usart_tx(screen);

	usart_tx(0x0D);	//	CR
	usart_tx(0x0A);	//	LF
}

uint8_t read_time(uint8_t dev_addr, uint8_t dev_regs)
{
	uint8_t time_val = 0;
	
	i2c_start();
	i2c_send(dev_addr);
	i2c_write(dev_regs);

	i2c_start();	//	re - start
	i2c_send(dev_addr | 0x01);	//	set in read mode

	time_val = i2c_NACK();
	i2c_stop();

	return time_val;
}

char i2c_start(void)
{

	TWCR = link_start;
	while(!(TWCR & (1<<TWINT)));

	usart_tx(0x01);
	link_status = (TWSR & 0xF8);
	usart_tx(link_status);

	return ( link_status==0x08 );
}

char i2c_send(uint8_t rtc_addr)
{
//	usart_tx(rtc_addr);

	TWDR = rtc_addr;
	TWCR = link_send;
	while(!(TWCR & (1<<TWINT)));

	link_status = (TWSR & 0xF8);
	usart_tx(0x02);
	usart_tx(link_status);

	while(link_status==0){	link_status = (TWSR & 0xF8);}
	usart_tx(link_status);
	return( link_status == 0x18 );
}

char i2c_write(uint8_t rtc_regs)
{
	TWDR = rtc_regs;
	TWCR = link_send;
	while(!(TWCR & (1<<TWINT)));
	
	usart_tx(0x03);
	
	link_status = (TWSR & 0xF8);
	usart_tx(link_status);

	if(link_status != 0x28)
		return 1;
	else
		return 0;
}

char i2c_NACK(void)
{
	TWCR = link_NACK;
	while(!(TWCR & (1<<TWINT)));
	usart_tx(0x04);

	link_status = (TWSR & 0xF8);
	usart_tx(link_status);

	return TWDR;
}

void i2c_stop(void)
{
	TWCR = link_stop;
	usart_tx(0x05);
}

Attachment(s): 

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

Quote:
I am very sorry to have posted in a wrong thread. But anybody who has an idea of it..help me out. The problem arises in i2c_send function in i2c_write_time(uint8_t, uint8_t, uint8_t) function.