Atmega32u4 USB support

nwrightson
Benutzer
Avatar
Gender:
Location: Newcastle
Age: 63
Homepage: nweha.homeserver.c…
Posts: 362
Registered: 08 / 2003
Subject:

Atmega32u4 USB support

 · 
Posted: 01.12.2012 - 07:39  ·  #1
Hi All,

I'm looking to buy a LeoStick and I'm wondering what USB support the Atmega32u4 has?



Are there any AVRCo drivers for the USB interfaces in the Mega chips yet?

I would like to communicate with a configuration application on the PC.

Neil.
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Atmega32u4 USB support

 · 
Posted: 02.12.2012 - 13:21  ·  #2
Hello Neil,

I accidentially deleted your last posting :'( . Sorry!
But why do you use this outdated Mega? The XMega32A4U is cheaper, faster and has an improved and much better internal USB hardware.

btw.
Atmel's strategy is to replace most of the current Megas by XMegas, which are cheaper and much more powerful. So new designs or redesigns should always use XMegas, if possible.

rolf
nwrightson
Benutzer
Avatar
Gender:
Location: Newcastle
Age: 63
Homepage: nweha.homeserver.c…
Posts: 362
Registered: 08 / 2003
Subject:

Re: Atmega32u4 USB support

 · 
Posted: 02.12.2012 - 20:53  ·  #3
Because it is already made.
So can I -
1. program it from avrco using the USB interface and atmels built in loader?

2. Does avrco support the USB functionality on this device?

3. The mega 128u sample program won't compile, error with missing endpoints.

Neil.
miparo
Administrator
Avatar
Gender:
Location: Germany
Age: 58
Posts: 959
Registered: 09 / 2007
Subject:

Re: Atmega32u4 USB support

 · 
Posted: 02.12.2012 - 23:15  ·  #4
Hi Neil,
my old Testprog wolks fine with Atmega32u.
1. no
2. yes. see my sample
3. little define error in AVRco !

miparo



Code


program Echo;

{ $NOSHADOW}
{ $WG-}                      {global Warnings on}

//Device = 90USB128, VCC=4.5;
//Device  = 90USB162,VCC=4.5;
//Device  = mega16U2;
Device  = mega32U4,  VCC=3.3;
//Device = mega32U6;



{ $BOOTRST $0F000}         {Reset Jump to $0F000}

(***********************************************************************
All CPU define were used only for my  development.
Atmel USB Devices Defines
{$IFDEF _USB16U4_32U4} -> Mega16U4, Mega32U4
{$IFDEF _USB32_64}     -> Mega32U6, 90USB64/646/647
{$IFDEF _USB128}       -> 90USB128/1286/1287
{$IFDEF _USB82_162}    -> 90USB82, 90USB162
{$IFDEF _USB8U2_32U2}  -> Mega8U2, Mega16U2, Mega32U2
************************************************************************)


Define_Fuses
  Override_Fuses;
  NoteBook       = B;
  COMport        = USB;
  Supply         = 5.0, 100;
  LockBits0      = [];
  FuseBits0      = [];
{$IFDEF _USB128}
  FuseBits1      = [SPIEN, JTAGEN, OCDEN];
{$ELSE}
  FuseBits1      = [SPIEN];
{$ENDIF}
  FuseBits2      = [];
{$IFDEF _USB16U4_32U4 or _USB128}
  ProgMode       = JTAG;
{$ELSE}  // Mega8U2, Mega16U2, Mega32U2  ,162
  ProgMode       = SPI;
{$ENDIF}

{$IFDEF _USB16U4_32U4}
Import SysTick, USBport,  BeepPort, WatchDog;
{$ELSE}
Import SysTick, USBport,  BeepPort, SerPort1;
{$ENDIF}

From System Import;

Define
  ProcClock      = 16000000;       {Hertz}
  SysTick        = 10;             {msec}
  StackSize      = $090, iData;
  FrameSize      = $090, iData;

{$IFNDEF _USB16U4_32U4}
  SerPort1        = 19200;
{$ENDIF}


{$IFDEF _USB128}
  BeepPort       = PortE, 5;
{$ELSIFDEF _USB16U4_32U4}
  BeepPort       = PortE, 2;  // MIRFscanner
{$ELSIFDEF _USB8U2_32U2}
  BeepPort       = PortD, 7;
{$ELSE}
  BeepPort       = PortD, 7;   // dummy
{$ENDIF}

//{$IFDEF _USB128}
  USBvid         = $9124;                // Vendor-ID
  USBpid         = 30;                  // Product-ID
  USBprodRel     = 201;                // Product-Release
  USBmanufact    = 'E-LAB Computers';
  USBprodName    = 'EvaBoard USB128';
  USBcurrent     = 200;                 // max current consumption
  USBsernum      = 2143;                // Product serial number
  USBendpoints   = 1;                   //  !!!!  help to compile until Rolf resolved  this :)
(*
{$ELSE}
  USBvid         = 9876;
  USBpid         = 1234;
  USBprodRel     = 3210;
  USBmanufact    = 'E-LAB Computers';
  USBprodName    = 'EvaBoard USBxxx';
  USBcurrent     = 200;
  USBsernum      = 7264;
{$ENDIF}
*)

Uses uAVR_USB;

Implementation

{$IDATA}

{--------------------------------------------------------------}
{ functions }
var
  USBrxBuf       : array[0..63] of byte;
  USBtxBuf       : array[0..63] of byte;
  Str63[@USBTxBuf[1]] : String[63];
  USBrxBuf8      : tEp3_4Buf,Align2;
  USBtxBuf8      : tEp3_4Buf,Align2;
  Str8[@USBTxBuf8[1]] : String[7];
  cnt            : Word;

  { functions }
Procedure myUserProc( x : byte;  v : word);
begin
  // ...
end;
{--------------------------------------------------------------}
{ Main Program }
{$IDATA}

begin
 // WatchDogStart;
  USBsetUserProc(@myUserProc);
  mDelay(500);
 // USBsetTimeOut(100);
  USBinit;
{$ifdef XMega}
  EnableInts($87);
{$else}
  EnableInts;
{$endif}

  BeepOutHL;
 {$IFNDEF _USB16U4_32U4}
  WriteLn(SerOut1, 'E-LAB USB Test');
 {$ENDIF}
  While not USBconnected do
    BeepClick;
    {$IFNDEF _USB16U4_32U4}
    SerOut1('x');
    {$ENDIF}
    mDelay(300);
  endwhile;
 {$IFNDEF _USB16U4_32U4}
  WriteLn(SerOut1);
  WriteLn(SerOut1, 'connected');
 {$ENDIF}

 Str63:='E-Lab Computers';
 Str8:='E-Lab C';
  loop
    if USBgetRxState8 > 0 then
      //cnt:=USBgetRxBuf8(USBrxBuf8);
    endif;
    if USBgetTxState8 > 0 then
      USBsetTxBuf8(USBtxBuf8);
    endif;
    if USBgetRxState > 0 then
      cnt:= USBgetRxBuf(@USBrxBuf, SizeOf(USBrxBuf));
      // Writeln(Serout,IntToStr(cnt));
    endif;
    if USBgetTxState > 0 then
      //WriteLn(SerOut, 'DownLen: '+IntToStr(USBgetTxState));
      cnt:= USBsetTxBuf(@USBtxBuf, SizeOf(USBtxBuf));

    endif;

  {$IFNDEF _USB16U4_32U4}
    if SerStat then
      case SerInp of
        'D', 'd' : USBclose;     // detach, disconnect
                 |
        'C', 'c' : USBinit;      // re-init
                 |
        'S', 's' : if USBconnected then
                     SerOut1('c');
                   else
                     SerOut1('x');
                   endif;      // status, connected
                 |
      else
        //BeepOut(1000, 10);

        SerOut1('?');
      endcase;
    endif;
   {$ENDIF}
  endloop;
end Echo.

rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Atmega32u4 USB support

 · 
Posted: 03.12.2012 - 20:51  ·  #5
Hello Neil,

USBendPoints are fixed in the MeagaUSB driver. So the define of EndPoints isnot necessary and is ignored.
Don't forget to define the Watchdog. It is necessary to send a hardware RESET via Endpoint0.

rolf
nwrightson
Benutzer
Avatar
Gender:
Location: Newcastle
Age: 63
Homepage: nweha.homeserver.c…
Posts: 362
Registered: 08 / 2003
Subject:

Re: Atmega32u4 USB support

 · 
Posted: 03.12.2012 - 21:36  ·  #6
Rolf,
Then why doesn't your Demo EVA128USB compile?
It gives an Error "Define of USBendpoints 1..2 Expected"
Neil.
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Atmega32u4 USB support

 · 
Posted: 04.12.2012 - 00:04  ·  #7
Hello Neil,

it is a bug but removed now. In the next update this define will be ignored.

rolf
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   126   140 · Page-Gen-Time: 0.040091s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI