atmega128

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
plukke

atmega128

Post by plukke » Tue Apr 03, 2007 3:16 pm

Hi

Had the link working perfectly on an Atmega16, but after upgrading to an Atmega128 I faced a problem. This is because pin D0 is also INT0 on this device. Are there any known solutions for this µc to get it working with the avr-usb link?

Thanks

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Tue Apr 03, 2007 5:25 pm

Simply use D0 for D+ and another bit for D-. Newer versions of AVR-USB accept any bit numbers for D+ and D-.

Plukke

Post by Plukke » Wed Apr 04, 2007 7:47 pm

Will go and try it out. Thans for the suggestion :)

plukke

Post by plukke » Thu Apr 05, 2007 3:37 pm

No succes yet....

Have tried on the Atmega16, and I could use any port or pin numbers and it works perfectly. However, when upgrading to the atmega128 Windows keeps buzzing me with the "Unrecognized Device" balloon.

I have tried numerous ports but witout succes. Are there any other suggestions I could try?

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Thu Apr 05, 2007 4:26 pm

Have you checked the obvious things:
  • Are the fuse bits configured for external crystal oscillator? The default is the internal RC oscillator.
  • Might the I/O pins used for D+ and D- be used for alternate functions?
  • Do you get any warnings from the compiler or assembler?

Guest

Post by Guest » Thu Apr 05, 2007 7:43 pm

I'm sure I'm using the right fuse bits, because when I disconnect the 12 MHz, I can't program my atMega128 anymore.

At the moment I’ve only connected the USB connector, so they are not used for something else.

My compiler and assembler doesn’t generate any warning or error. I’m using the command prompt (Win XP) and I change directory to the place where my main.c exists. Then, I type “make” and I see a list of files which are being compiled. But I don’t see any warnings or errors. See the screenshot below to see my compiler output.

I only get an error about the checksize option, but this is not important to the compilation process. I’m using AVR Studio to program my ATMega128.

Image

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Thu Apr 05, 2007 9:01 pm

And are you sure you have changed the makefile to compile for the right target?

We have not tested AVR-USB with the ATMega128 yet, but I see no reason why it should not work. If there would be any address range problems, the compiler or assembler should print an error or at least a warning.

Guest

plukke

Post by Guest » Thu Apr 05, 2007 9:51 pm

Yes, I've changed the target to Atmega128. That's the only thing I've changed. I'va connected ecerything following the circuit that came with the zipfile PowerSwitch.2007-03-29.zip.

Here is a link to my makefile: makefile

( I've changed the extension to .txt so it could be downloaded. )

The only change is the device variable

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Thu Apr 05, 2007 10:47 pm

Interesting... Do you have any debug tools available such as a digital storage scope, a logic analyzer or at least a simple analog scope?

With a DSO, you should see a query/response dialog on D+, query and response being distinguished by slightly different voltage levels. Simple errors can usually be seen on the scope.

From the software side you might be able to see something with a USB snooper, but that assumes that there is at least SOME communication.

And another idea: The Mega128 has an XDIV register where you can divide the crystal frequency. Are you sure that this feature is disabled?

Grendel
Rank 4
Rank 4
Posts: 167
Joined: Sat Dec 16, 2006 9:53 pm
Location: Oregon, USA
Contact:

Post by Grendel » Fri Apr 06, 2007 2:48 am

Hm, is the M103C fuse programmed (it is by default) ? If so, kill it.

Plukke

Post by Plukke » Fri Apr 06, 2007 2:49 pm

I've placed this statement:

XDIV = (0<<XDIVEN);

at the first line of my main-function. Following the datasheet this means that the clock divider is disabled, so the atmega128 runs at 12 mHz.

At this moment I don't have a scope or logic analyzer avaible. Tuesday, when I'm at school I can use one. I will post the results here, then.

@ Grendel, the Mega103 compatibility mode is disabled (bit unprogrammed). I've tried both options.

So, I don't have any succes yet.

Grendel
Rank 4
Rank 4
Posts: 167
Joined: Sat Dec 16, 2006 9:53 pm
Location: Oregon, USA
Contact:

Post by Grendel » Mon Apr 09, 2007 9:38 am

Odd that changing the M103C fuse doesn't change the behavior.. Could you post the values of the three fuse bytes ? I would suggest these values:

Extended fuse byte -- 0xFF
High fuse byte -- 0xD9
Low fuse byte -- 0x9F

Also, what version of WinAVR are you using ? 20060421 or 20070122 ? (the latter is claimed to be "somewhat experimental"..)

plukke

Post by plukke » Tue Apr 10, 2007 4:07 pm

At last, it works :shock:
I changed the fusebits to the values suggested, made no effect whatsoever. Then I pulled out the scope.

After plugging the chip to the scope, I noticed the USB signal was quite nasty, loads of round edges, no nice sharp edges. Plugging it into the ATMEGA16 revealed a nice signal with sharp edges. So now I knew it wasnt the chip itself, it was the hardware around it.

After replacing the pullup resistors and adding two 3V6 zener diodes I managed to get the signal right. After all it wasn't the chip itself, it proved to be other factors.

Thanks bigtime for the help and support :)

ari

Re: atmega128

Post by ari » Sat Jul 25, 2009 9:56 am

Can someone send this file for sendspce or something that Guest gived (makefile.txt) pls?

Arxidatos

Re: atmega128

Post by Arxidatos » Wed Feb 10, 2010 1:19 am

I am newby at AVR and because i couldn't find an ATTINY45 i used an ATMEGA128 to test and practice with the code provided at CAPSLOCK project http://macetech.com/blog/?q=node/46. I used port D 2 for usb D- and port D 0 for usb D+ clocked into usbconfig.h with a 16MHz ceramic resonator the fuses WDTON 1,OCNED 1,JTAGEN 0,CKOPT 0, EESAVE 1, BOOTSZ1-2 0, BOOTRST 1, BODLEVEL 0, BOTEN 0, SUT1 1, SUT0 0, and all CKEL 1, initially the communication was not possible and was getting the message unknown device. after i solder into the interface circuit the 3V6 zeners all gone perfect. one more note for the timer TCCR1 use a 16bit value because for atmega128 this timer is 16bit.

I loved the project and the code :D excellent !!!

Post Reply