AVR to PC communication through USB

Discussion in 'Embedded Systems and Microcontrollers' started by dsp_redux, Jul 30, 2010.

  1. dsp_redux

    Thread Starter Active Member

    Apr 11, 2009
    182
    5
    Hi,

    I'm working on a project using an ATMEGA32U2 (http://www.atmel.com/dyn/resources/prod_documents/doc7799.pdf) which already has a USB controller in it. From what I understand, I need to set USBE=1 (USB enable) to initialize the USB controller. Then... what? Let's say I have informations in internal EEPROM, do I just go and plug the PC and AVR through USB and that's it? The PC will see the info just like a USB key?

    I know it can't be that simple, but where do I go from there?
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Have you posted your question at www.avrfreaks.net? If not, you should give that a try. The members there have a wide range of experience with such things.

    hgmjr
     
    dsp_redux likes this.
  3. dsp_redux

    Thread Starter Active Member

    Apr 11, 2009
    182
    5
    That was my B plan.
    Code ( (Unknown Language)):
    1.  
    2. if(NB_ANS_AAC_FORUM == 0){
    3.         OPEN_ACCOUNT("AVRFREAKS");
    4.         ASK_QUESTION();
    5.         HOPE();
    6. }
    7. else {
    8.         BE_HAPPY_WITH ONLY ONE ACCOUNT();
    9. }
    10.  
    Sooner or later, I'll have to register an account there :p.
     
  4. Papabravo

    Expert

    Feb 24, 2006
    10,138
    1,789
    Doing a USB interface will be way more complicated than you can possibly imagine. Go to www.usb.org and download the documents there. In order to talk to a PC you will have to go through a process called enumeration. Every time you answer incorrectly the PC will shut down the connection leaving you to wonder what your mistake was. WORSE your registry will contain corrupted information that will require manual deletion so that the enumeration process can be started over with a fresh slate.

    If you don't have a USB traffic analyzer, such as a Beagle, get one! You have no chance to debug the enumeration process without one.
     
    Last edited: Jul 30, 2010
    dsp_redux likes this.
  5. dsp_redux

    Thread Starter Active Member

    Apr 11, 2009
    182
    5
    Even with a USB enabled AVR?
     
  6. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    I would go with your plan B.

    hgmjr
     
    dsp_redux likes this.
  7. Papabravo

    Expert

    Feb 24, 2006
    10,138
    1,789
    It's all in the firmware that you must write to use the USB enabled AVR. It is the data that you send back during the enumeration process that is critical to getting a USB link up and working
     
    dsp_redux likes this.
  8. dsp_redux

    Thread Starter Active Member

    Apr 11, 2009
    182
    5
    I agree that the USB 2.0 spec needs some time before it can be digested. Or I use something like LUFA, or I byte the bullet and go through this. Since time on this project is not critical, I guess I'll do what Supertramp tells me, I'll take the long way home.
     
  9. dsp_redux

    Thread Starter Active Member

    Apr 11, 2009
    182
    5
    Thanks for the insights PapaBravo and hgmrj.
     
  10. Papabravo

    Expert

    Feb 24, 2006
    10,138
    1,789
    LUFA??, Supertramp?? What are they?
     
  11. dsp_redux

    Thread Starter Active Member

    Apr 11, 2009
    182
    5
  12. Papabravo

    Expert

    Feb 24, 2006
    10,138
    1,789
    Do you have the AVR-GCC compiler up and working?
    I think understanding LUFA well enough to use it may present it own challenges.
     
  13. dsp_redux

    Thread Starter Active Member

    Apr 11, 2009
    182
    5
    AVR-GCC is up and running. I'll dig more into USB specs before using LUFA.
     
  14. GetDeviceInfo

    Senior Member

    Jun 7, 2009
    1,571
    230
    Depends on how familiar you are with the USB protocols. If you check on the Atmel website, you'll find several examples of USB code in the evaluation board sections.

    On the PC side, there are a number of tools that provide direct access to USB devices. I've found that Labview has an excellent set of tools for working with USB devices.
     
Loading...