ATmega32U2 and AT90USB162.

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

First, as far as I can see, these are pin compatbile. Correct?

Second, If I read the datasheet correctly, they are delivered with the flash read/write protected. Correct?

Third, If I read the datasheet correctly, ICSP is disabled when they come from the factory. How would I enable ICSP? High Voltage Programming? If I don't have a HVP programmer, it doesn't make sense to put an ICSP connector on my board, right?

Last, in the "bootloader" datasheet, the ATMEGA32U2 is not mentioned. But it DOES come with a bootloader, right?

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

[full disclosure: I know virtually nothing about USB AVRs]

I pulled up the datasheet and searched for "ICSP" and got no hits. ??? SPIEN is enabled as is normal in AVRs.

There appears to be an HWBE fuse that is enabled by default. That, coupled with the lock bit settings, would imply to me that there is something (a bootloader) in the chip. Maybe Dean or others familiar with the series can clarify.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Likewise. I am ignorant.

At a guess, the ATmega32U2 can be soldered directly onto a pcb that contains a crystal and a USB socket.

You program your applications via the USB socket using FLIP. You can set lockbits via FLIP.

So you have your whole application up and running without an ISP programmer. The application is secure. The application can be updated or replaced. Your punters cannot go trashing fuses etc.

Witness all those Freaks sobbing that they cannot terrify users with tales of HVPP.

However, if you want to add an ISP header or JTAG header you are perfectly at liberty to do so. Then Freaks can destroy bootloaders, trash fuses, frighten punters, feel very important....

David.

Last Edited: Wed. Aug 18, 2010 - 03:08 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

or JTAG header

Well, perhaps a debugWire setup?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

All the AT90USB (including the U2/U4s) come preloaded with the DFU bootloader which is programmed by the "Flip" Java app from with Windows or Linux.

The chips also have standard ISP and dW interfaces with ISP enabled by default (dW needs ISp to be used to flip the DWEN fuse)

(for the uninitiated ICSP is Microchip's word for ISP)

As it happens I downloaded Flip a couple of days ago and the following picture are the ATmega/AT90USB it supports at present...

PS I gotta ask - have you actually found somewhere with ATmega32U2 in stock and if so how much? (I'm more interested in ATmega16U2 in fact - you can get a Microchip PIC18F14K50 (16KB/USB) for £1.22)

Attachment(s): 

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

David, I can't suppress thinking of: http://www.youtube.com/watch?v=O... when I see your name... Different David Prentice though, I believe...

"Further research" has determined that I need a crystal to have USB work. So for the bootloader to work, the chip would have to be configured for external crystal clock. I haven't verified that.

But is it configured for a 8MHz or a 16MHz crystal? I can't get the board recognized when I connect it. (I connected an 8 MHz crystal as I had ONE of those, and none 16MHz... :-)

Thinking ICSP wouldn't work anyway, I haven't designed an ICSP connector on the board. :-( Oh well. Next revision.

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

No. It is not me paragliding!

No. I have not used a mega32U2.

Looking at para25.2 on p248 of the data sheet, it implies the fuses are set for 8MHz crystal. It also seems that the BOOTRST fuse is not checked, so presumably at RESET it will just skip through until it reaches the Bootloader code.

I can only suggest that you look at reference AT90USB162 designs.

Dean (abcminiuser) can probably help you.

Note that the
http://www.engbedded.com/fusecalc/
gives a different default set of fuses to the data sheet.

David.

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

I found a hint that it MUST be 16MHz: Check the manual section 3.3.1 on page 7.

http://www.reworld.eu/re/en/prod...

(I'll try again tomorrow when I get my 16MHz crystals).

(I'll gladly take you on a tandem Paragliding flight, at my cost, just to be able to say that I took David Prentice on a tandem flight, as a bragging item in the paragliding world.. :-) ) (That offer applies to any of the three David Prentice's I know about, or anybody named Will Gadd, Bruce Goldsmith or Mike Kung. :-) )

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

Quote:

PS I gotta ask - have you actually found somewhere with ATmega32U2 in stock and if so how much?

http://search.digikey.com/script... $2.63/100

The smaller ones seem to be scarce. ;)

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

I have used the atmega32u4 and to activate the bootloader two pins needs to be set to 0 :reset and HWB.
I put a 20k resistor to ground on HWB pin so i only need to press the reset button to activate the bootloader.
The bootloader should work with 8 or 16 mhz crystals.

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

Ok... the USB connector's ground pin needs to be connected to the board...
And the XTAL2 pin should NOT be shorted to ground.... Now that's solved I've got my USB device.

Next step: running FLIP. Suggestions?

It seems that the flip 3.2.1 version available on Atmel's site does not support the atmega32u2, whereas 3.4.1 is only available for Windows.

Borrowed a friend's Windows machine....

I have flashing leds! Good news!

But PD0 seems to be dead. It seems to be high impedance. The program is really simple:

int main ()
{
  int i;

  EIMSK = 0;
  PCICR = 0;

  PCMSK0 =
  PCMSK1 = 0;


  DDRD = 0x3f;
  DDRC = 0x04;

  while (1) {
     PORTD = 0x0f;
     PORTC = 4;
     delay_ms (150);
     PORTD = 0x30;
     PORTC = 0;
     delay_ms (150);
  }
}

It's an input because shorting it to either side makes the led on PD0 flash as it should. But PD0 remains an input. Any suggestions? (I've added the interrupts disable stuff to be sure that it is not configured as an input due to its secondary function: external interrupt).

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

Hi people!
I want to make USBTiny mkII, it uses AT90USB162, may I use as substitute Mega32U4 ?? it have USB to,
it's beacause there is no AT90USB in stores in whole Poland !
Will firmaware - hex for this AT90USB work in M32U4??
Probably not, but maybe someone now something?
Can someone compile the source if PDI programmer for M32u4?
Or maybe another uC will work??
And... can programmer ISP for M32 program M32u4?

Polandball
 

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

The hex file from Tom's website will not work, however the original source code - the AVRISP-MKII clone in my LUFA project - can be recompiled just fine for the ATMEGA32U4.

- Dean :twisted:

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

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

So...Would you compile that for Meh?
Or tell me what source I should compile and what should I change.
You now, SPI of M32u4 is ISP for target and the D+/- from usb.
Im just beginner in electronic.

Polandball
 

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

Sure, but you'll have to tell me which AVR pin you'd like to use for the target's /RESET line, and you'll also need to pick an ADC channel for the ISP pin's VTARGET pin.

- Dean :twisted:

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

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

Well, SPI in M32 would be ISP for target, SS pin is reset for target >(PB0-PB3), data from usb to USB pins in m32, Leds on PB6-7, i hope thats all - if not - tell me.
What cyrstal do i need ? 16 or 12Mhz?
Would be much better with 12Mhz, i got SMD one.
What is the purpose of transistor near of the USB port, do i have to have it on board??
Regards.

Polandball
 

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

I got another question, is there any difrences between M32U2 and U4 (binary)?
May use m32u2 instead m32u4, i ment if hez for U4 will work on U2(after pin change)?
My shops don't have m32u4, only u2

Polandball
 

Last Edited: Wed. Sep 22, 2010 - 11:33 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

U2 is a much cut down version of the U4. Surely you can see this when you compare their datasheets?

You could also compare the bullet points on a site like Farnell:

http://uk.farnell.com/atmel/atme...
http://uk.farnell.com/atmel/atme...

You'll see that one is a 32pin device, the other 44 pin. The smaller with 22 I/O while the larger has 26 I/O. The larger has ADC, the smaller doesn't. And so on...

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

Ok. thx
@abcminiuser
Well, i have to ask if you compiled the hex for usbtinymkII?
I red (here on avrf) that soft for at90usb162 can work on M32u2 - is that truth???
Then i could use already existing hex!
If not, please compile this for M32u2...
I now Im asking to much. Sorry.

Polandball
 

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

Yes, the USB162 hex should work perfectly if that's the one you have - the pinouts are compatible and so is the binary. If you've got access to one of those, just load the USBTINY-MKII precompiled HEX on it.

- Dean :twisted:

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

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

No1: I want to be sure - the reset for TPI and ISP is from PB4 and it's active ONLY when it's programming the device?
I'm asking cause the PB4 is pulled to Vcc with resistor.
The reset for ISP and TPI is NOT active all the time by firmware??
No2: Is this gonna work if the level converter is made only with voltage divider with resistors (like in MMC cards using with AVR's for 5V)?
That is my remake scheme:
Is it correct logicaly (i changed only connectors pinout)?
What should I change?
If anybody want, I can upload Board in PDF, but it have ONLY ISP and PDI connectors.

Attachment(s): 

Polandball
 

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

Are you able to re-draw the schematic please? The way you've got it there looks more like a PCB rats nest before layout, which makes reading difficult.

- Dean :twisted:

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

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

I don' really understand, it's quite simple...
Should be compatibile with this
http://elportal.pl/n0020/usbtiny...
And I don't understand what is S3 for.

Polandball
 

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

Ah, that one's much more readable. Looks fine - S3 is used to enter the bootloader along with S1, so that you can reprogram the USB AVR through the USB interface. Not sure what Q1's doing there, however - do you know why that is in the schematic?

- Dean :twisted:

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

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

No, i have no idea what is q1 for.
And m32u2 will be programmed by classic lpt programmer.
And my idea with resistor divider instead of max3002 was awfull.
But I try zener diode, it will be making 3.3V level for target, and will not decreasing level of signal from target.

Polandball
 

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

PD7 has a function of /HWB and is used to enter bootloader. But if you are going to factory program your AVR via USB only once, there is no need for that button - core will hit boot section anyway. If you plan to use a stabilized version of your software, there is no need to upgrade it and all the memory can be utilized (using ISP).

The transistor on a schematics is not a transistor, but a PESD12V double Zener diode. It protects D+/D- pins from ESD. It was placed on a schematics that way, because the author could not find a SOT23 PESD12V element in a library.

I do not think USB certification requires that external ESD protection, but mind AT90USB162 is capable of using PS2 as its input.

Quote:
And my idea with resistor divider instead of max3002 was awfull.

MISO levels of AT90USB162@5V are set below 1.5V so a 1.8V AVR slave will drive it correctly without a problem.

No RSTDISBL, no fun!

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

Quote:
MISO levels of AT90USB162@5V are set below 1.5V so a 1.8V AVR slave will drive it correctly without a problem.

So we don't need to use any level converter (cause xmega is NOT 5V tolerant) from M32u2 @ 5V to program 3.3V xmega??
I'm confused now.

In normal work mode is Xmega 5V tolernat at normal IO pins?

Polandball
 

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

I do not know XMegas. The question was about ATMega162 running at 5V schematics.
Every signal on MISO higher than 1.5V is treated as "HIGH" by the AT90 chip. So if you apply 1.49V it is not obvious AT90 understands it HIGH. But if you apply 1.6V at MISO, it always does.

With LOW state it is much easier (see the datasheet).

MOSI,SCK,SS are outputs for AT90 so you must know they are driven from ~0V(LOW) to ~Vcc(about 5V) (HIGH) and AT90 does not sense them.

If you want to know a level converter parameters, you must check both datasheets of devices you connect, more advanced designers assume wiring impedance, calculate step responses and so on. With low frequencies it is enough to calculate current flow at a steady state.

Quote:
So we don't need to use any level converter (cause xmega is NOT 5V tolerant)

AT90USB has a linear regulator on-board and it happens to be a fixed 3.3V@50mA one. Switch into 3.3V and all your problems are gone.

Quote:
In normal work mode is Xmega 5V tolernat at normal IO pins?

You must check all the voltage ranges AT90 and XMega can have (worst case). By advertising "5V tolerant" manufacturers often mean TTL level compatible(able to drive and sense that signal).

http://en.wikipedia.org/wiki/Log...

No RSTDISBL, no fun!

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

In xmega datasheet i can't find anything about 5V tolerant, so probably is not tolerant.
And M32u2 for 16Mhz Need over 4.5V, its for PDI programmer...I could use 3.3V for M32u2, but it wouldn't work on 16Mhz.
Anyway thx for theese info.

Polandball
 

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

Quote:
And M32u2 for 16Mhz Need over 4.5V, its for PDI programmer...I could use 3.3V for M32u2, but it wouldn't work on 16Mhz.

The choice is yours. You can run it at 3.3V@8MHz without any glue logic or run it with 4.5V@16MHz adding glue logic (I suppose several resistors in your case).

Besides PDI is not SPI and it requires some intelligence, MOSI must be tied to MISO and switched between input and output - this requires some attention.

You can also try using USART in SPI mode - this one is even faster.

No RSTDISBL, no fun!

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

In xmega I don't need any usart or spi - i don't now what you talking about.
All i wanna now, is the xmega can be programmed by M32u2/at90usb directly , with no any zeners, resistors or logic level converters.
I making the pdi programmer - usbtinymkII, from scheme above.

Polandball
 

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

To build an ISP programmer running at 5V that can program 3.3V targets you need to do something about the voltage disparity. Suggest you look at the USBtinyISP schematic:

http://www.ladyada.net/images/us...

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

PDI interface uses USART and PD2 is RXD of USART and PD3 is TXD of USART. RXD logic levels are slightly different than MISO/MOSI.

Quote:
All i wanna now, is the xmega can be programmed by M32u2/at90usb directly , with no any zeners, resistors or logic level converters.

The answer to this question is simple: No, because even the simplest level converters (voltage dividers) require resistors at least.

No RSTDISBL, no fun!

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

So maybe i try zeners, for decrease signals from M32u2 to 3.3V ?
It will decrease from programmer, and will not decreease level from target to M32u2? M32u2 will now the high level about 3.3V .

Polandball
 

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

Ok i made that, i programmed m32u2 by Atmel Flip, its got firmware nr. 100807, and it's visible for WinXP in sys. as "LibUSB win32 devices > Avrisp mkii", it got some drivers from WinAvr folder.
I'll try to program xmega in this week.
I hope that is all correct, if not, tell me what drivers i should install instead.

Polandball
 

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

K. Working with Atmega128, i test xmega later.
Thx for tips and helping.
But there is some problem , on my comp. it's invisible for AVRstudio4, but on the other one laptop it's working normal, any tip??

Ok, i just needed SPack 3 for avrstudio.

Polandball